Uh oh!
There was an error while loading. Please reload this page.
lib: reuse invalid state errors on webstreams - #46086
Conversation
nodejs-github-bot
commented
Jan 4, 2023
nodejs-github-bot
commented
Jan 4, 2023
Uh oh!
There was an error while loading. Please reload this page.
mcollina
left a comment
There was a problem hiding this comment.
What's the stack trace of this error? Make sure it does should not include any user lines.
Uh oh!
There was an error while loading. Please reload this page.
I can remove the UPDATE: I've updated to use |
97dff7d to
4540f14Comparemcollina
commented
Jan 7, 2023
what's the final stack trace for these then? What's t.js in your stacktrace above? |
4540f14 to
9f94cb9CompareStacktrace rafaelgss@rafaelgss-desktop:~/repos/os/node$ ./node t.jsnode:internal/errors:490 ErrorCaptureStackTrace(err); ^TypeError [ERR_INVALID_STATE]: Invalid state: Reader released at readableStreamReaderGenericRelease (node:internal/webstreams/readablestream:2079:30) at readableStreamDefaultReaderRelease (node:internal/webstreams/readablestream:2043:3) at ReadableStreamDefaultReader.releaseLock (node:internal/webstreams/readablestream:833:5) at main (/home/rafaelgss/repos/os/node/t.js:13:10) { code: 'ERR_INVALID_STATE'}Node.js v20.0.0-pre
const{ ReadableStream }=require('node:stream/web')asyncfunctionmain(){conststream=newReadableStream({start(controller){controller.close();},});constreader=stream.getReader();awaitreader.closed;reader.releaseLock();// the error is created hereawaitreader.closed;// this should throw the invalid state error}main()Reference: https://github.com/nodejs/node/blob/main/test/parallel/test-whatwg-readablestream.js#L479 |
mcollina
commented
Jan 7, 2023
Unfortunately, you'd need to remove everything that's not internal, otherwise users could be utterly confused. |
9f94cb9 to
42c40edCompareRafaelGSS
commented
Jan 9, 2023
@mcollina What about it now? |
There was a problem hiding this comment.
This is a good start but it won't match all internal frames. There are e.g., not always brackets involved.
The best one to match I could come up with was: const coreModuleRegExp = /^ {4}at (?:[^/\\(]+ \(|)node:(.+):\d+:\d+\)?$/;
There was a problem hiding this comment.
Thanks! I've changed it a bit to perform the inverse operation (userland modules). Can you double-check?
Signed-off-by: RafaelGSS <rafael.nunu@hotmail.com>
42c40ed to
4c65282Comparenodejs-github-bot
commented
Jan 11, 2023
nodejs-github-bot
commented
Jan 13, 2023
Landed in 5d50b84 |
Signed-off-by: RafaelGSS <rafael.nunu@hotmail.com> PR-URL: nodejs#46086 Reviewed-By: Robert Nagy <ronagy@icloud.com> Reviewed-By: Yagiz Nizipli <yagiz@nizipli.com> Reviewed-By: Matteo Collina <matteo.collina@gmail.com>
Signed-off-by: RafaelGSS <rafael.nunu@hotmail.com> PR-URL: nodejs#46086 Reviewed-By: Robert Nagy <ronagy@icloud.com> Reviewed-By: Yagiz Nizipli <yagiz@nizipli.com> Reviewed-By: Matteo Collina <matteo.collina@gmail.com>
Signed-off-by: RafaelGSS <rafael.nunu@hotmail.com> PR-URL: #46086 Reviewed-By: Robert Nagy <ronagy@icloud.com> Reviewed-By: Yagiz Nizipli <yagiz@nizipli.com> Reviewed-By: Matteo Collina <matteo.collina@gmail.com>
Signed-off-by: RafaelGSS <rafael.nunu@hotmail.com> PR-URL: #46086 Reviewed-By: Robert Nagy <ronagy@icloud.com> Reviewed-By: Yagiz Nizipli <yagiz@nizipli.com> Reviewed-By: Matteo Collina <matteo.collina@gmail.com>
Signed-off-by: RafaelGSS <rafael.nunu@hotmail.com> PR-URL: #46086 Reviewed-By: Robert Nagy <ronagy@icloud.com> Reviewed-By: Yagiz Nizipli <yagiz@nizipli.com> Reviewed-By: Matteo Collina <matteo.collina@gmail.com>
We are tracking internally the webstreams performance and after some investigation (nodejs/undici#1203, nodejs/performance#9 (comment)), we found that one of the bottlenecks is the
NodeErrorcreation.undici.fetchas a real use case of web streams, the benchmark files are available at https://github.com/RafaelGSS/nodejs-webstreams-perf/blob/main/bench/fetch.jsundici.fetchperformance by approximately 23%.I'm not quite sure about the security impacts of this change, considering we're going to use the same object for all release calls.
More information on this performance work can be found at nodejs/performance#9.