Git Product home page Git Product logo

Comments (14)

NaitLee avatar NaitLee commented on May 27, 2024

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.

rejetto avatar rejetto commented on May 27, 2024

would you please open a separate issue for highWatermark?

from hfs.

NaitLee avatar NaitLee commented on May 27, 2024

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 ðŸ˜Ē And go***mn the docs and internet stuffs that are messy and confused me

from hfs.

NaitLee avatar NaitLee commented on May 27, 2024

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.

rejetto avatar rejetto commented on May 27, 2024

i hope to find a better solution but had no time to look into this atm

from hfs.

rejetto avatar rejetto commented on May 27, 2024

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.

rejetto avatar rejetto commented on May 27, 2024

i've just found this
https://nodejs.org/api/stream.html#streamiserroredstream
worth a try?

from hfs.

NaitLee avatar NaitLee commented on May 27, 2024

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.

rejetto avatar rejetto commented on May 27, 2024

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.

NaitLee avatar NaitLee commented on May 27, 2024

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.

rejetto avatar rejetto commented on May 27, 2024

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.

NaitLee avatar NaitLee commented on May 27, 2024

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.

rejetto avatar rejetto commented on May 27, 2024

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.

rejetto avatar rejetto commented on May 27, 2024
        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)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google âĪïļ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.