-
Notifications
You must be signed in to change notification settings - Fork 29.6k
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
util: adhere to noDeprecation
set at runtime
#6683
Conversation
}); | ||
|
||
const internalUtil = require('internal/util'); | ||
internalUtil.printDeprecationMessage('Something 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.
Can you add a check that calling printDeprecationMessage()
after setting process.noDeprecation
to false
again does emit a deprecation warning?
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!
8ce7305
to
9180ec8
Compare
Nice, LGTM. |
const assert = require('assert'); | ||
|
||
function listener(warning) { | ||
assert.notStrictEqual(warning.name, 'DeprecationWarning'); |
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.
If I am not wrong this function should not be called right? I think assert(false, 'this should not be called');
or something like this would be better I guess.
9180ec8
to
26eabd1
Compare
Updated based on @thefourtheye’s suggestion. |
const assert = require('assert'); | ||
|
||
function listener(warning) { | ||
assert.fail(null, null, 'received unexpected warning'); |
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.
Mostly LGTM, good catch. |
26eabd1
to
d8abe30
Compare
@Fishrock123 looking better now? :) |
const common = require('../common'); | ||
const assert = require('assert'); | ||
|
||
function listener(warning) { |
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.
Unused warning
?
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.
@Fishrock123 eh, yes, sorry. fixed.
Yeah. Another CI would be nice before landing once that nit is fixed |
fe73664
to
372ea85
Compare
const assert = require('assert'); | ||
|
||
function listener(warning) { | ||
common.fail('received unexpected warning'); |
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.
this could fail if any other warnings happened to be emitted in the future. The warning
object can be checked to see if it is a DeprecationWarning
by looking at the name
property or the message
can be checked explicitly.
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.
That's unlikely though, is it? That would mean core is doing something internally that is worthy of warning. I'd consider that a bug.
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.
Wasn't commenting on the likeliness of it... just the possibility of it. ;-)
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.
@jasnell lol, literally what I had written here at first. But @thefourtheye made a good point, if there are other warnings emitted in the future, it’s probably best to know about that, even if that might mean having to change the test file again.
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.
;-) ok @addaleax ... sgtm
Until now, the docs stated that `process.noDeprecation` could be set at runtime, but before any modules were loaded. That was not true, because `lib/internal/util.js` was loaded during the process startup process, so setting the flag at runtime was pointless. Minimal test case: process.noDeprecation = true; process.EventEmitter; This patch moves checking `process.noDeprecation` to the place where it was actually used.
372ea85
to
dc8ea89
Compare
LGTM |
LGTM. CI is green. |
Until now, the docs stated that `process.noDeprecation` could be set at runtime, but before any modules were loaded. That was not true, because `lib/internal/util.js` was loaded during the process startup process, so setting the flag at runtime was pointless. Minimal test case: process.noDeprecation = true; process.EventEmitter; This patch moves checking `process.noDeprecation` to the place where it was actually used. PR-URL: #6683 Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl> Reviewed-By: Jeremiah Senkpiel <fishrock123@rocketmail.com> Reviewed-By: Sakthipriyan Vairamani <thechargingvolcano@gmail.com> Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Landed in a4564f3 |
Until now, the docs stated that `process.noDeprecation` could be set at runtime, but before any modules were loaded. That was not true, because `lib/internal/util.js` was loaded during the process startup process, so setting the flag at runtime was pointless. Minimal test case: process.noDeprecation = true; process.EventEmitter; This patch moves checking `process.noDeprecation` to the place where it was actually used. PR-URL: #6683 Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl> Reviewed-By: Jeremiah Senkpiel <fishrock123@rocketmail.com> Reviewed-By: Sakthipriyan Vairamani <thechargingvolcano@gmail.com> Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
- **buffer**: fix lastIndexOf and indexOf in various edge cases (Anna Henningsen) [#6511](#6511) - **child_process**: use /system/bin/sh on android (Ben Noordhuis) [#6745](#6745) - **deps**: - upgrade npm to 3.8.9 (Rebecca Turner) [#6664](#6664) - upgrade to V8 5.0.71.47 (Ali Ijaz Sheikh) [#6572](#6572) - upgrade libuv to 1.9.1 (Saúl Ibarra Corretgé) [#6796](#6796) - Intl: ICU 57 bump (Steven R. Loomis) [#6088](#6088) - **repl**: - copying tabs shouldn't trigger completion (Eugene Obrezkov) [#5958](#5958) - exports `Recoverable` (Blake Embrey) [#3488](#3488) - **src**: add O_NOATIME constant (Rich Trott) [#6492](#6492) - **src,module**: add --preserve-symlinks command line flag (James M Snell) [#6537](#6537) - **util**: adhere to `noDeprecation` set at runtime (Anna Henningsen) [#6683](#6683)
- **buffer**: fix lastIndexOf and indexOf in various edge cases (Anna Henningsen) [#6511](#6511) - **child_process**: use /system/bin/sh on android (Ben Noordhuis) [#6745](#6745) - **deps**: - upgrade npm to 3.8.9 (Rebecca Turner) [#6664](#6664) - upgrade to V8 5.0.71.47 (Ali Ijaz Sheikh) [#6572](#6572) - upgrade libuv to 1.9.1 (Saúl Ibarra Corretgé) [#6796](#6796) - Intl: ICU 57 bump (Steven R. Loomis) [#6088](#6088) - **repl**: - copying tabs shouldn't trigger completion (Eugene Obrezkov) [#5958](#5958) - exports `Recoverable` (Blake Embrey) [#3488](#3488) - **src**: add O_NOATIME constant (Rich Trott) [#6492](#6492) - **src,module**: add --preserve-symlinks command line flag (James M Snell) [#6537](#6537) - **util**: adhere to `noDeprecation` set at runtime (Anna Henningsen) [#6683](#6683) As of this release the 6.X line now includes 64-bit binaries for Linux on Power Systems running in big endian mode in addition to the existing 64-bit binaries for running in little endian mode. PR-URL: #6810
- **buffer**: fix lastIndexOf and indexOf in various edge cases (Anna Henningsen) [#6511](#6511) - **child_process**: use /system/bin/sh on android (Ben Noordhuis) [#6745](#6745) - **deps**: - upgrade npm to 3.8.9 (Rebecca Turner) [#6664](#6664) - upgrade to V8 5.0.71.47 (Ali Ijaz Sheikh) [#6572](#6572) - upgrade libuv to 1.9.1 (Saúl Ibarra Corretgé) [#6796](#6796) - Intl: ICU 57 bump (Steven R. Loomis) [#6088](#6088) - **repl**: - copying tabs shouldn't trigger completion (Eugene Obrezkov) [#5958](#5958) - exports `Recoverable` (Blake Embrey) [#3488](#3488) - **src**: add O_NOATIME constant (Rich Trott) [#6492](#6492) - **src,module**: add --preserve-symlinks command line flag (James M Snell) [#6537](#6537) - **util**: adhere to `noDeprecation` set at runtime (Anna Henningsen) [#6683](#6683) As of this release the 6.X line now includes 64-bit binaries for Linux on Power Systems running in big endian mode in addition to the existing 64-bit binaries for running in little endian mode. PR-URL: #6810
@addaleax lts? |
Nope, the behaviour in v4.x is fine already. |
Checklist
Affected core subsystem(s)
process (util?)
Description of change
Until now, the docs stated that
process.noDeprecation
could be set at runtime, but before any modules were loaded. That was not true, becauselib/internal/util.js
was loaded during the process startup process, so setting the flag at runtime was always pointless.Minimal test case:
This patch moves checking
process.noDeprecation
to the place where it was actually used./cc @jasnell
CI: https://ci.nodejs.org/job/node-test-commit/3263/