Comments (14)
I just see there's Readable.unshift
. It can "put back" but not that beautiful.
I'll continue anyway. Looking forward to your thoughts :)
from hfs.
would you please open a separate issue for highWatermark?
from hfs.
would you please open a separate issue for highWatermark?
Let me just remove it, Node is confusing me again.
I'd make it clear later. I need more test because I get false stuffs all the way.
One matter is certain: be aware of potential memory problem.
Very sorry about that
from hfs.
I think my migration is done: the commit
... and my use of Readable.unshift
here
This can be closed, if you think unshift
is good enough
from hfs.
i hope to find a better solution but had no time to look into this atm
from hfs.
ok, this may not be perfect but maybe it's good enough: i could add a failed
property to the Readable.
function fail(code: any) {
if (!sse)
return new ApiError(code)
list.error(code)
return Object.assign(list.return, { failed: code }) // allow local code (plugins) to easily read failure code
}
Another option is to call Readable.destroy(error)
function fail(code: any) {
if (!sse)
return new ApiError(code)
list.error(code)
list.return.destroy(code)
return list.return
}
This seems cleaner, but I guess you cannot simply "read" the error in this case. You'd probably have to setup a listener for the error event.
Do you want to evaluate these solutions yourself?
We may even do both
from hfs.
i've just found this
https://nodejs.org/api/stream.html#streamiserroredstream
worth a try?
from hfs.
I tested and I can get error code from "error" event, via that destroy
But then default frontend can't get it (the old problem)
Maybe you can make those sendList
operations into a subclass inheriting Readable
, and add failed
attribute etc:
class SendListReadable<T> extends Readable {
failed: number | undefined;
add(rec: T) { this.push({ add: rec }); }
// ...
error(msg: number) {
this.push({ error: msg });
this.failed = msg;
}
}
And use its instances :)
from hfs.
yeah, why not
but i protected the property, and gave it a more generic name, because i don't know if it's always a fatal failure like for file_list.
Have a look at last commit, if it suits you
from hfs.
Remove this, as it's even destroying the default frontend
(to reproduce: browse a protected folder without permission, you get 404 by node exception, not 401 file_list without response)
After that everything works...
from hfs.
i can't succeed reproducing the problem.
My frontend doesn't list protected folders unless you have access, so I cannot actually click the folder.
If I, instead, enter the url directly, I get the 401 from the first request, correctly. In this case file_list is actually useless and shouldn't be called, but it is called anyway (should be fixed), and I can see that it transmitted {error:401} as well.
Are you sure about the problem? Any idea?
That line is actually not very important, and leave the connection open even if we are not going to send anything else.
It could easily be removed if we are not sure it is causing no harm.
from hfs.
I tested with Node.js version 16.15.1 (LTS) and 18.3.0 (my local version),
with both linux and wine/exe, (though in this case system doesn't matter)
wIth default frontend,
view protected folder without permission (yes by entering address) --
16: shows login prompt. Page request is 401 and file_list request is 200, inside is error object. Proper.
18: shows listing page but listing process hangs there, with "Stop List" blinking. Page request is 401 but file_list is aborted (no response), and exception of Node in terminal (even when non-DEV), indicating 401 was not handled
Well, another dirty job of Node. They even didn't say what's up in doc update history.
While, in my plugin I have:
await once(readable_list, 'readable');
When "infected" by this, destroy
will make it equivalent to:
throw new Error(404); // whatever, abort here
Disaster
Easy & Direct approach is simply don't destroy
...
Edit: maybe push null
instead, to actually end it
from hfs.
thank you very much for your useful testing.
You are right, it's a shame there's this different behaviour if it's not documented.
I want to play a bit with it in node18 to see if I understand something more.
null
is definitely an option.
from hfs.
list.error(code)
setTimeout(() => list.destroy(code))
this is also a solution.
But I think i should go for list.end()
instead, that's, you know, the null
.
pushed!
from hfs.
Related Issues (20)
- Antidos e non solo HOT 9
- Language contribution to HFS HOT 8
- NET::ERR_CERT_AUTHORITY_INVALID HOT 9
- HFS translation into French utf-8 format HOT 1
- Login HOT 5
- Http cookie problem , when Https connexion is OK HOT 1
- Portuguese Translation. HOT 1
- Add hfs to Homebrew please HOT 4
- Add prev|next methods to Entry object HOT 4
- Support external repos in plugin info HOT 22
- Change directory event HOT 10
- Direct link to access the file WITHOUT authorization HOT 2
- web setting language is invalid
- Access via Webdav HOT 3
- ERR: fom translate and up to HFS HOT 3
- FEATURE: hope owner add VI (vietnam) as Embedded language HOT 7
- ASK: make HFS public with sub-domain (No-IP) HOT 1
- HELP: has certificate but NOT has private key HOT 27
- Updated Russian translation for 0.46 HOT 5
- Log entry for successful downloads HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
ð Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. ððð
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google âĪïļ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from hfs.