| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
|
It's probably worth noting what happens when a readFile() is aborted (an error is raised in one form or another) and the limitations of aborting a readFile() call (e.g. it does not abort queued requests at the libuv level, so it will always wait for the current request to finish first). |
Sorry, something went wrong.
Sorry, something went wrong.
There was a problem hiding this comment.
Why using a DOMException? As a user I would prefer to receive one of our error objects with a code.
Sorry, something went wrong.
There was a problem hiding this comment.
This is recommended by the spec: https://dom.spec.whatwg.org/#aborting-ongoing-activities
Users are supposed to check for it with error.name === 'AbortError'
Sorry, something went wrong.
There was a problem hiding this comment.
We are telling our users to check for an error code. I think that should be the way to go here as well.
Note that I'd like the error code to be specific for fs.readFile, so it's easy to debug.
Sorry, something went wrong.
There was a problem hiding this comment.
@mcollina this is what we use everywhere else that uses AbortSignals (like events.once and timers/promises) and everywhere in the web standard (like fetch). I feel strongly that this should be compatible with how exceptions work everywhere else.
A code is already set on DOMExceptions (as ABORT_ERR ) see internal/per_context/domexception - we can recommend the code as the way to check rather than the name in the docs if you think that's better.
Sorry, something went wrong.
There was a problem hiding this comment.
I've likely missed it everywhere else. This seems really hard to debug: users will not know what this aborterror is about in a complex application.
Let's not hold this for it.. I'll open an issue when I have the time.
Sorry, something went wrong.
There was a problem hiding this comment.
I've likely missed it everywhere else. This seems really hard to debug: users will not know what this aborterror is about in a complex application.
Why? Would it help if this had a different .code? I am happy to set the code to something different here and reject with a subclass if you think that improves DX. I can also do that for timers (though like you said probably better in a different PX).
Note I'm not convinced DX is actually better with "different aborts cancel with different codes since by far the most common the use case I saw is checking for cancellation (in general) to ignore the error (since cancellation is not an error most times). Users can also figure where cancellation came from from the stack trace.
Let's not hold this for it.. I'll open an issue when I have the time.
Sure, note you are currently blocking - is that intentional?
Sorry, something went wrong.
|
(Sorry I made a mess from the mobile interface). |
Sorry, something went wrong.
There was a problem hiding this comment.
lgtm
Sorry, something went wrong.
Sorry, something went wrong.
Sorry, something went wrong.
Sorry, something went wrong.
Commit Queue failed- Loading data for nodejs/node/pull/35911 ✔ Done loading data for nodejs/node/pull/35911 ----------------------------------- PR info ------------------------------------ Title fs: add support for AbortSignal in readFile (#35911) ⚠ Could not retrieve the email or name of the PR author's from user's GitHub profile! Branch benjamingr:readfile-abort-signal -> nodejs:master Labels fs, semver-minor Commits 1 - fs: add support for AbortSignal in readFile Committers 1 - Benjamin Gruenbaum PR-URL: https://github.com/nodejs/node/pull/35911 Reviewed-By: James M Snell Reviewed-By: Anna Henningsen Reviewed-By: Matteo Collina Reviewed-By: Rich Trott Reviewed-By: Michaël Zasso ------------------------------ Generated metadata ------------------------------ PR-URL: https://github.com/nodejs/node/pull/35911 Reviewed-By: James M Snell Reviewed-By: Anna Henningsen Reviewed-By: Matteo Collina Reviewed-By: Rich Trott Reviewed-By: Michaël Zasso -------------------------------------------------------------------------------- ⚠ Commits were pushed since the last review: ⚠ - fs: add support for AbortSignal in readFile ✖ Last GitHub CI failed ℹ Last Full PR CI on 2020-11-05T18:03:50Z: https://ci.nodejs.org/job/node-test-pull-request/34099/ - Querying data for job/node-test-pull-request/34099/ ✔ Build data downloaded ✔ Last Jenkins CI successful ℹ This PR was created on Sun, 01 Nov 2020 16:25:00 GMT ✔ Approvals: 5 ✔ - James M Snell (@jasnell) (TSC): https://github.com/nodejs/node/pull/35911#pullrequestreview-521239795 ✔ - Anna Henningsen (@addaleax): https://github.com/nodejs/node/pull/35911#pullrequestreview-521251093 ✔ - Matteo Collina (@mcollina) (TSC): https://github.com/nodejs/node/pull/35911#pullrequestreview-521540648 ✔ - Rich Trott (@Trott) (TSC): https://github.com/nodejs/node/pull/35911#pullrequestreview-521671149 ✔ - Michaël Zasso (@targos) (TSC): https://github.com/nodejs/node/pull/35911#pullrequestreview-521863433 -------------------------------------------------------------------------------- ✔ Aborted `git node land` session in /home/runner/work/node/node/.ncu Commit Queue action: https://github.com/nodejs/node/actions/runs/348132668 |
Sorry, something went wrong.
PR-URL: #35911 Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Anna Henningsen <anna@addaleax.net> Reviewed-By: Matteo Collina <matteo.collina@gmail.com> Reviewed-By: Rich Trott <rtrott@gmail.com> Reviewed-By: Michaël Zasso <targos@protonmail.com>
PR-URL: #35911 Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Anna Henningsen <anna@addaleax.net> Reviewed-By: Matteo Collina <matteo.collina@gmail.com> Reviewed-By: Rich Trott <rtrott@gmail.com> Reviewed-By: Michaël Zasso <targos@protonmail.com>
Notable changes: * events: * getEventListeners static (Benjamin Gruenbaum) (#35991) * fs: * support abortsignal in writeFile (Benjamin Gruenbaum) (#35993) * add support for AbortSignal in readFile (Benjamin Gruenbaum) (#35911) * stream: * fix thrown object reference (Gil Pedersen) (#36065) PR URL: #36055
Notable changes: * events: * getEventListeners static (Benjamin Gruenbaum) (#35991) * fs: * support abortsignal in writeFile (Benjamin Gruenbaum) (#35993) * add support for AbortSignal in readFile (Benjamin Gruenbaum) (#35911) * stream: * fix thrown object reference (Gil Pedersen) (#36065) PR URL: #36055
Notable changes: * events: * getEventListeners static (Benjamin Gruenbaum) (#35991) * fs: * support abortsignal in writeFile (Benjamin Gruenbaum) (#35993) * add support for AbortSignal in readFile (Benjamin Gruenbaum) (#35911) * stream: * fix thrown object reference (Gil Pedersen) (#36065) PR URL: #36055
PR-URL: nodejs#35911 Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Anna Henningsen <anna@addaleax.net> Reviewed-By: Matteo Collina <matteo.collina@gmail.com> Reviewed-By: Rich Trott <rtrott@gmail.com> Reviewed-By: Michaël Zasso <targos@protonmail.com>
Refs: nodejs#33716 Refs: nodejs#35993 Refs: nodejs#35911
Refs: #33716 Refs: #35993 Refs: #35911 PR-URL: #39972 Reviewed-By: Michaël Zasso <targos@protonmail.com> Reviewed-By: Luigi Pinca <luigipinca@gmail.com> Reviewed-By: Juan José Arboleda <soyjuanarbol@gmail.com> Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Darshan Sen <raisinten@gmail.com> Reviewed-By: Tobias Nießen <tniessen@tnie.de>
PR-URL: #39972 Refs: #33716 Refs: #35993 Refs: #35911 Reviewed-By: Michaël Zasso <targos@protonmail.com> Reviewed-By: Luigi Pinca <luigipinca@gmail.com> Reviewed-By: Juan José Arboleda <soyjuanarbol@gmail.com> Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Darshan Sen <raisinten@gmail.com> Reviewed-By: Tobias Nießen <tniessen@tnie.de>
Refs: #33716 Refs: #35993 Refs: #35911 PR-URL: #39972 Reviewed-By: Michaël Zasso <targos@protonmail.com> Reviewed-By: Luigi Pinca <luigipinca@gmail.com> Reviewed-By: Juan José Arboleda <soyjuanarbol@gmail.com> Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Darshan Sen <raisinten@gmail.com> Reviewed-By: Tobias Nießen <tniessen@tnie.de>
| Back | FazBrowse Home | New Git URL |
Add basic support for AbortSignal in readFile.
This adds support just to readFile and fs.promises.readFile and not anything else in FS (unless you include fileHandle.readFile).
This is because it's significantly easier to do for readFile since the cancellation doesn't have to happen in libuv land and since readFile is a really heavy and pretty common action.
cc @jasnell @mcollina @addaleax