| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
There was a problem hiding this comment.
This function's implementation should be changed too. In fact, I'd rather just get rid of rethrow() altogether and just copy the throw ... where needed as I don't see the value in having a function that all it does is throw an exception (+ it avoids a potential function call).
Sorry, something went wrong.
There was a problem hiding this comment.
Might be worth benchmarking. I thought using throw directly could de-opt a function? I had some fairly mysterious regressions in performance when doing some tiny refactors like this with an old experiment.
Sorry, something went wrong.
There was a problem hiding this comment.
@sam-github Not throwing, but try-catch/try-finally used to. However I think with the V8 in node v7.x, functions containing try-catch/try-finally are optimizable, but are still not inlineable (not sure if the inlineability limit was with Crankshaft or TurboFan or both though).
Sorry, something went wrong.
There was a problem hiding this comment.
Definite +1 to getting rid of rethrow() if we can
Sorry, something went wrong.
There was a problem hiding this comment.
I refactored it a little bit to get rid of rethrow. PTAL.
Sorry, something went wrong.
|
This would require a documentation change both fs.md and deprecations.md (Item id DEP0013). The deprecation description would need to be updated to show that not passing a callback is "end-of-life" and that an error will now be thrown. (The entry must not be removed from deprecations.md tho) |
Sorry, something went wrong.
There was a problem hiding this comment.
Wherever this error ends up being thrown, please include a comment that indicates that this previously was a deprecation with ID code DEP0013
Sorry, something went wrong.
There was a problem hiding this comment.
Since this is semver-major already, please migrate the error to use the new internal/errors.js API.
Sorry, something went wrong.
There was a problem hiding this comment.
Done!
Sorry, something went wrong.
There was a problem hiding this comment.
Definite +1 to getting rid of rethrow() if we can
Sorry, something went wrong.
There was a problem hiding this comment.
Almost there!
Sorry, something went wrong.
There was a problem hiding this comment.
These can be changed to use common.expectsError({code: 'ERR_INVALID_CALLBACK'})
Sorry, something went wrong.
There was a problem hiding this comment.
alternatively this could be fs.close(fd, common.noop), but this works also.
Sorry, something went wrong.
There was a problem hiding this comment.
const cbTypeError = common.expectsError({code: 'ERR_INVALID_CALLBACK'});
Sorry, something went wrong.
There was a problem hiding this comment.
ditto ... I'll stop pointing these out.
Sorry, something went wrong.
|
Thanks @jasnell :-) Updated the PR as per your suggestions. |
Sorry, something went wrong.
There was a problem hiding this comment.
Can the conditionals' bodies be placed on separate lines please?
Sorry, something went wrong.
|
FWIW I still prefer to see the check/throw copied where needed instead of making maybeCallback() the new rethrow(). |
Sorry, something went wrong.
|
@mscdex Addressed your comments now. PTAL. |
Sorry, something went wrong.
Sorry, something went wrong.
There was a problem hiding this comment.
I would still prefer to stick with REPLACEME for the versions themselves (unless you’re reasonably sure that this doesn’t need to be fixed up again 😄 )
Sorry, something went wrong.
There was a problem hiding this comment.
Sure, updated to REPLACEME now. PTAL.
Sorry, something went wrong.
If an asynchronous function is passed no callback function, there is no way to return the result. This patch throws an error if the callback passed is not valid or none passed at all.
Sorry, something went wrong.
|
CI is green. I'll land this tomorrow, if there are no objections. |
Sorry, something went wrong.
Sorry, something went wrong.
If an asynchronous function is passed no callback function, there is no way to return the result. This patch throws an error if the callback passed is not valid or none passed at all. PR-URL: #12562 Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Anna Henningsen <anna@addaleax.net>
This reverts 4cb5f3d Based on community feedback I think we should consider reverting this change. We should explore how this could be solved via linting rules. Refs: #12562 PR-URL: #12976 Reviewed-By: Sakthipriyan Vairamani <thechargingvolcano@gmail.com> Reviewed-By: Evan Lucas <evanlucas@me.com> Reviewed-By: Colin Ihrig <cjihrig@gmail.com> Reviewed-By: Rich Trott <rtrott@gmail.com>
This reverts 4cb5f3d Based on community feedback I think we should consider reverting this change. We should explore how this could be solved via linting rules. Refs: #12562 PR-URL: #12976 Reviewed-By: Sakthipriyan Vairamani <thechargingvolcano@gmail.com> Reviewed-By: Evan Lucas <evanlucas@me.com> Reviewed-By: Colin Ihrig <cjihrig@gmail.com> Reviewed-By: Rich Trott <rtrott@gmail.com>
|
Not providing callback to async function, is similar to not providing an error handler to event listener. In latter case node.js throws since very early days, and it seems as great pattern that works for most developers. So taking this in (not just as a depreaction warning), will just make error handling in Node.js more consistent (and for 100% coverage we also need #12010 ) |
Sorry, something went wrong.
This reverts commit 8250bfd. PR-URL: nodejs#18668 Refs: nodejs#12562 Refs: nodejs#12976 Reviewed-By: Matteo Collina <matteo.collina@gmail.com> Reviewed-By: Michaël Zasso <targos@protonmail.com> Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl> Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Joyee Cheung <joyeec9h3@gmail.com> Reviewed-By: Gus Caplan <me@gus.host>
The callback should run in the global scope and not in the FSReqWrap context. PR-URL: nodejs#18668 Refs: nodejs#12562 Refs: nodejs#12976 Reviewed-By: Matteo Collina <matteo.collina@gmail.com> Reviewed-By: Michaël Zasso <targos@protonmail.com> Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl> Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Joyee Cheung <joyeec9h3@gmail.com> Reviewed-By: Gus Caplan <me@gus.host>
* v10.0.0 -> Node.js 10.0.0 * Parenthetical with URL rather than "PR" as a lot of people may not know what "PR" stands for but they will know what a URL is. Plus not hiding the URL means the text is more copy/paste-able. In this particular case, "PR 12562" is not more useful or informative than nodejs#12562 so just use the URL.
* v10.0.0 -> Node.js 10.0.0 * Parenthetical with URL rather than "PR" as a lot of people may not know what "PR" stands for but they will know what a URL is. Plus not hiding the URL means the text is more copy/paste-able. In this particular case, "PR 12562" is not more useful or informative than nodejs#12562 so just use the URL. PR-URL: nodejs#20519 Reviewed-By: Vse Mozhet Byt <vsemozhetbyt@gmail.com> Reviewed-By: Refael Ackermann <refack@gmail.com> Reviewed-By: Luigi Pinca <luigipinca@gmail.com> Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de> Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Trivikram Kamat <trivikr.dev@gmail.com>
This reverts commit 8250bfd. PR-URL: nodejs#18668 Refs: nodejs#12562 Refs: nodejs#12976 Reviewed-By: Matteo Collina <matteo.collina@gmail.com> Reviewed-By: Michaël Zasso <targos@protonmail.com> Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl> Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Joyee Cheung <joyeec9h3@gmail.com> Reviewed-By: Gus Caplan <me@gus.host>
The callback should run in the global scope and not in the FSReqWrap context. PR-URL: nodejs#18668 Refs: nodejs#12562 Refs: nodejs#12976 Reviewed-By: Matteo Collina <matteo.collina@gmail.com> Reviewed-By: Michaël Zasso <targos@protonmail.com> Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl> Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Joyee Cheung <joyeec9h3@gmail.com> Reviewed-By: Gus Caplan <me@gus.host>
* v10.0.0 -> Node.js 10.0.0 * Parenthetical with URL rather than "PR" as a lot of people may not know what "PR" stands for but they will know what a URL is. Plus not hiding the URL means the text is more copy/paste-able. In this particular case, "PR 12562" is not more useful or informative than #12562 so just use the URL. PR-URL: #20519 Reviewed-By: Vse Mozhet Byt <vsemozhetbyt@gmail.com> Reviewed-By: Refael Ackermann <refack@gmail.com> Reviewed-By: Luigi Pinca <luigipinca@gmail.com> Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de> Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Trivikram Kamat <trivikr.dev@gmail.com>
* v10.0.0 -> Node.js 10.0.0 * Parenthetical with URL rather than "PR" as a lot of people may not know what "PR" stands for but they will know what a URL is. Plus not hiding the URL means the text is more copy/paste-able. In this particular case, "PR 12562" is not more useful or informative than #12562 so just use the URL. PR-URL: #20519 Reviewed-By: Vse Mozhet Byt <vsemozhetbyt@gmail.com> Reviewed-By: Refael Ackermann <refack@gmail.com> Reviewed-By: Luigi Pinca <luigipinca@gmail.com> Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de> Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Trivikram Kamat <trivikr.dev@gmail.com>
* v10.0.0 -> Node.js 10.0.0 * Parenthetical with URL rather than "PR" as a lot of people may not know what "PR" stands for but they will know what a URL is. Plus not hiding the URL means the text is more copy/paste-able. In this particular case, "PR 12562" is not more useful or informative than #12562 so just use the URL. PR-URL: #20519 Reviewed-By: Vse Mozhet Byt <vsemozhetbyt@gmail.com> Reviewed-By: Refael Ackermann <refack@gmail.com> Reviewed-By: Luigi Pinca <luigipinca@gmail.com> Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de> Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Trivikram Kamat <trivikr.dev@gmail.com>
As per this nodejs/node#12562 node PR callback in async fs functions is no longer optional. This commit fixes remaining usages in impress.
As per this nodejs/node#12562 node PR callback in async fs functions is no longer optional. This commit fixes remaining usages in impress. Refs: #852 PR-URL: #856
Now mandatory in NodeJS 10. See nodejs/node#12562
| Back | FazBrowse Home | New Git URL |
If an asynchronous function is passed no callback function, there is no
way to return the result. This patch throws an error if the callback
passed is not valid or none passed at all.
Checklist
Affected core subsystem(s)
fs
@nodejs/ctc