Repository navigation
doc: document --no-warnings=<cat1>,<cat2> #46862
Description
Activity
- addeddocIssues and PRs related to Node.js documentation.Issues and PRs related to Node.js documentation.good first issueIssues that are suitable for first-time contributors.Issues that are suitable for first-time contributors.
on Feb 27, 2023 Hi Ben, I have tried the
--no-warningsflag with=<xxWarning>but it looks like it would just suppress all the warnings instead of the one I explicitly set, maybe I used it incorrectly?The code sample I tested locally:
const EventEmitter = require('events').EventEmitter; const eventEmitter = new EventEmitter(); for (i = 0; i < 11; i++) { eventEmitter.on('', () => {}); } setTimeout(() => {}, 2 ** 32); // print: // (node:87253) MaxListenersExceededWarning: Possible EventEmitter memory leak detected. 11 listeners added to // [EventEmitter]. Use emitter.setMaxListeners() to increase limit // (Use `node --trace-warnings ...` to show where the warning was created) // (node:87253) TimeoutOverflowWarning: 4294967296 does not fit into a 32-bit signed integer. // Timeout duration was set to 1.
I tried
--no-warnings=MaxListenersExceededWarningand it also suppressedTimeoutOverflowWarningfrom setTimeout.Tested on node 14 and current main branch, same results.
--no-warnings=...doesn't work at the granularity of individual warning classes, just:-
categories, of which I believe there are currently only three: DeprecationWarning, ExperimentalWarning and V8; or
-
deprecation numbers; DEP0001, DEP0002, etc.
Reacted by jakecastelli-
I have tried
--no-warnings=DEP0024which is deprecation warning forsysconst assert = require('assert'); const sys = require('sys'); try { assert.fail('a', 'b') } catch(err) {}
I would expect the console to suppress the deprecation warning for
sysbut still show me theDEP0094which is the deprecation warning forassert.failwith more than 2 args.However it looks like it has suppressed all the warnings 🤔
Would you mind pointing out where the source code for parsing the flag 🙏 cheers!
The warning for
require('sys')is DEP0025, not DEP0024. :-)It's possible suppressing specific deprecation warnings no longer works. Like I said, it's functionality that's undocumented and - worse - untested so it quite possibly bitrotted.
Reacted by jakecastelliSorry I had a typo, meant to type
DEP0025.I tried to search where this functionality resides in the code base but didn't find it :(
this will be my first issue to start with, can I take this one?
Sure, go ahead.
Reacted by Moshe AtlowI have tried to use
--no-warnings=ExperimentalWarningand--no-warnings=DeprecationWarning, but it is neither accepting any of the option, basically suppressing all type of warnings. But--no-deprecationcommand-line flag can be used to suppress deprecation warnings. It is mentioned in the documentation already I just iterated that.`'use strict'; const EventEmitter = require('events').EventEmitter; const eventEmitter = new EventEmitter(); for (let i = 0; i < 11; i++) { eventEmitter.on('', () => {}); } setTimeout(() => {}, 2 ** 32); const assert = require('assert'); const sys = require('sys'); try { assert.fail('a', 'b') } catch(err) {}`Hi jagadeeshmeesala if you are not working on this can i take this
- added a commit that references this issue
on Sep 8, 2023 - added a commit that references this issue
on Sep 28, 2023 FWIW the
--no-warningsflag does not accept anything. It isbooleanonly and will disable all warnings when enabled.Reacted by Max Nanasy- added a commit that references this issue
on Nov 21, 2023 - added a commit that references this issue
on Nov 23, 2023 - added a commit that references this issue
on Nov 27, 2023 - added 2 commits that reference this issue
on Nov 29, 2023 - added 3 commits that reference this issue
on Dec 11, 2023
Refs #30810.
Node allows suppression of e.g. experimental warnings with
--no-warnings=ExperimentalWarningbut that syntax is completely undocumented. Even the warning categories aren't documented anywhere, as far as I can tell.The way node parses flags means its inversion
--warnings=ExperimentalWarningpossibly also does something meaningful but I haven't checked.