-
Notifications
You must be signed in to change notification settings - Fork 29.7k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fs: warn instead of throwing if no callback #7897
fs: warn instead of throwing if no callback #7897
Conversation
if (typeof cb !== 'function') { | ||
if (typeof cb === 'undefined') { | ||
// TODO throw error instead of deprecation warning in v8.0.0 | ||
let m = 'async function calls without valid callbacks is deprecated.'; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: are deprecated
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done.
citgm: https://ci.nodejs.org/view/Node.js-citgm/job/thealphanerd-smoker-xunit/39/ I like the approach here. +1 for this over the revert |
@@ -95,7 +98,14 @@ function sanitizeFD(fd) { | |||
// for callbacks that are passed to the binding layer, callbacks that are | |||
// invoked from JS already run in the proper scope. | |||
function makeCallback(cb) { | |||
if (typeof cb !== 'function') { | |||
if (typeof cb === 'undefined') { | |||
// TODO throw error instead of deprecation warning in v8.0.0 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I did remember the other TODO/FIXME/etc.'s format is not like this, suggest:
// TODO(thefourtheye): throw error instead of deprecation warning in v8.0.0
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done.
citgm failing:
|
Do you guys know how I can locally reproduce this problem? |
|
Wait, this should not fail though. I'll investigate further, a little later. |
@@ -95,7 +98,15 @@ function sanitizeFD(fd) { | |||
// for callbacks that are passed to the binding layer, callbacks that are | |||
// invoked from JS already run in the proper scope. | |||
function makeCallback(cb) { | |||
if (typeof cb !== 'function') { | |||
if (typeof cb === 'undefined') { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You can just compare cb === undefined
.
A test case validating that the deprecation warning is emitted would be good. With that added this LGTM |
@thefourtheye As expected, this conflicts now… I think it’s okay to apply the changes that got reverted here again (with the intention to squash in the warnings?). Sorry for the trouble the process is causing you! |
ping @thefourtheye |
3b0ece0
to
c2d6f53
Compare
Updated with the deprecation warning alone. PTAL people. |
@@ -112,10 +113,13 @@ function maybeCallback(cb) { | |||
// invoked from JS already run in the proper scope. | |||
function makeCallback(cb) { | |||
if (cb === undefined) { | |||
// TODO(thefourtheye) throw error instead of warning in major version > 7 | |||
let m = 'asynchronous function calls without callbacks is deprecated.'; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
are deprecated
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
or even better, make it singular.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@silverwind Done.
Actually, let me take that back... this uses For instance: process.emitWarning(depMessage, 'DeprecationWarning'); By passing ping @thefourtheye |
c2d6f53
to
5b8a2e4
Compare
@jasnell I modified it to use |
@thefourtheye ... That partially handles it. See #8166. I'm attempting to move things away from using the internal util printDeprecationMessage. |
fe1b569
to
c8b8d4b
Compare
LGTM with a nit if CI is green. |
This patch issues a deprecation warning, if an asynchronous function is called without a callback function.
5ff4aa2
to
3e97e2c
Compare
LGTM if CI is green |
@nodejs/ctc ... as a semver-major this needs another CTC signoff... |
LGTM |
Thanks for the review people. Landed in f8f283b |
This patch issues a deprecation warning, if an asynchronous function is called without a callback function. PR-URL: #7897 Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Yorkie Liu <yorkiefixer@gmail.com> Reviewed-By: Anna Henningsen <anna@addaleax.net>
Notable Changes: * Buffer * Passing invalid input to Buffer.byteLength will now throw an error [nodejs#8946](nodejs#8946). * Calling Buffer without new is now deprecated and will emit a process warning [nodejs#8169](nodejs#8169). * Passing a negative number to allocUnsafe will now throw an error [nodejs#7079](nodejs#7079). * Child Process * The fork and execFile methods now have stronger argument validation [nodejs#7399](nodejs#7399). * Cluster * The worker.suicide method is deprecated and will emit a process warning [nodejs#3747](nodejs#3747). * Deps * V8 has been updated to 5.4.500.36 [nodejs#8317](nodejs#8317), [nodejs#8852](nodejs#8852), [nodejs#9253](nodejs#9253). * NODE_MODULE_VERSION has been updated to 51 [nodejs#8808](nodejs#8808). * File System * A process warning is emitted if a callback is not passed to async file system methods [nodejs#7897](nodejs#7897). * Intl * Intl.v8BreakIterator constructor has been deprecated and will emit a process warning [nodejs#8908](nodejs#8908). * Promises * Unhandled Promise rejections have been deprecated and will emit a process warning [nodejs#8217](nodejs#8217). * Punycode * The `punycode` module has been deprecated [nodejs#7941](nodejs#7941). * URL * An Experimental WHATWG URL Parser has been introduced [nodejs#7448](nodejs#7448).
Notable Changes: * Buffer * Passing invalid input to Buffer.byteLength will now throw an error [#8946](#8946). * Calling Buffer without new is now deprecated and will emit a process warning [#8169](#8169). * Passing a negative number to allocUnsafe will now throw an error [#7079](#7079). * Child Process * The fork and execFile methods now have stronger argument validation [#7399](#7399). * Cluster * The worker.suicide method is deprecated and will emit a process warning [#3747](#3747). * Deps * V8 has been updated to 5.4.500.36 [#8317](#8317), [#8852](#8852), [#9253](#9253). * NODE_MODULE_VERSION has been updated to 51 [#8808](#8808). * File System * A process warning is emitted if a callback is not passed to async file system methods [#7897](#7897). * Intl * Intl.v8BreakIterator constructor has been deprecated and will emit a process warning [#8908](#8908). * Promises * Unhandled Promise rejections have been deprecated and will emit a process warning [#8217](#8217). * Punycode * The `punycode` module has been deprecated [#7941](#7941). * URL * An Experimental WHATWG URL Parser has been introduced [#7448](#7448). PR-URL: #9099
Notable Changes: * Buffer * Passing invalid input to Buffer.byteLength will now throw an error [#8946](#8946). * Calling Buffer without new is now deprecated and will emit a process warning [#8169](#8169). * Passing a negative number to allocUnsafe will now throw an error [#7079](#7079). * Child Process * The fork and execFile methods now have stronger argument validation [#7399](#7399). * Cluster * The worker.suicide method is deprecated and will emit a process warning [#3747](#3747). * Deps * V8 has been updated to 5.4.500.36 [#8317](#8317), [#8852](#8852), [#9253](#9253). * NODE_MODULE_VERSION has been updated to 51 [#8808](#8808). * File System * A process warning is emitted if a callback is not passed to async file system methods [#7897](#7897). * Intl * Intl.v8BreakIterator constructor has been deprecated and will emit a process warning [#8908](#8908). * Promises * Unhandled Promise rejections have been deprecated and will emit a process warning [#8217](#8217). * Punycode * The `punycode` module has been deprecated [#7941](#7941). * URL * An Experimental WHATWG URL Parser has been introduced [#7448](#7448). PR-URL: #9099
Notable Changes: * Buffer * Passing invalid input to Buffer.byteLength will now throw an error [#8946](nodejs/node#8946). * Calling Buffer without new is now deprecated and will emit a process warning [#8169](nodejs/node#8169). * Passing a negative number to allocUnsafe will now throw an error [#7079](nodejs/node#7079). * Child Process * The fork and execFile methods now have stronger argument validation [#7399](nodejs/node#7399). * Cluster * The worker.suicide method is deprecated and will emit a process warning [#3747](nodejs/node#3747). * Deps * V8 has been updated to 5.4.500.36 [#8317](nodejs/node#8317), [#8852](nodejs/node#8852), [#9253](nodejs/node#9253). * NODE_MODULE_VERSION has been updated to 51 [#8808](nodejs/node#8808). * File System * A process warning is emitted if a callback is not passed to async file system methods [#7897](nodejs/node#7897). * Intl * Intl.v8BreakIterator constructor has been deprecated and will emit a process warning [#8908](nodejs/node#8908). * Promises * Unhandled Promise rejections have been deprecated and will emit a process warning [#8217](nodejs/node#8217). * Punycode * The `punycode` module has been deprecated [#7941](nodejs/node#7941). * URL * An Experimental WHATWG URL Parser has been introduced [#7448](nodejs/node#7448). Signed-off-by: Ilkka Myller <ilkka.myller@nodefield.com>
Checklist
make -j4 test
(UNIX), orvcbuild test nosign
(Windows) passesAffected core subsystem(s)
fs
Description of change
9359de9
made sure that if no callback function is passed to asynchronous
functions, the system will throw.
But, this breaks a lot of existing modules including npm (Refer:
#7846). Till all the necessary
dependencies use the async functions properly, no module can work.
So, this patch issues a deprecation warning, instead of throwing and
the throwing behaviour will be restored in the next major release.
cc @ChALkeR @nodejs/collaborators @nodejs/ctc