Skip to content
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

doc: document --no-warnings=<cat1>,<cat2> #46862

Closed
bnoordhuis opened this issue Feb 27, 2023 · 11 comments · Fixed by #50661
Closed

doc: document --no-warnings=<cat1>,<cat2> #46862

bnoordhuis opened this issue Feb 27, 2023 · 11 comments · Fixed by #50661
Labels
doc Issues and PRs related to the documentations. good first issue Issues that are suitable for first-time contributors.

Comments

@bnoordhuis
Copy link
Member

bnoordhuis commented Feb 27, 2023

Refs #30810.

Node allows suppression of e.g. experimental warnings with --no-warnings=ExperimentalWarning but 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=ExperimentalWarning possibly also does something meaningful but I haven't checked.

@bnoordhuis bnoordhuis added doc Issues and PRs related to the documentations. good first issue Issues that are suitable for first-time contributors. labels Feb 27, 2023
@jakecastelli
Copy link
Member

jakecastelli commented Feb 27, 2023

Hi Ben, I have tried the --no-warnings flag 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=MaxListenersExceededWarning and it also suppressed TimeoutOverflowWarning from setTimeout.

Tested on node 14 and current main branch, same results.

@bnoordhuis
Copy link
Member Author

--no-warnings=... doesn't work at the granularity of individual warning classes, just:

  1. categories, of which I believe there are currently only three: DeprecationWarning, ExperimentalWarning and V8; or

  2. deprecation numbers; DEP0001, DEP0002, etc.

@jakecastelli
Copy link
Member

jakecastelli commented Feb 28, 2023

I have tried --no-warnings=DEP0024 which is deprecation warning for sys

const 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 sys but still show me the DEP0094 which is the deprecation warning for assert.fail with 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!

@bnoordhuis
Copy link
Member Author

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.

@jakecastelli
Copy link
Member

Sorry 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 :(

@jagadeeshmeesala
Copy link

this will be my first issue to start with, can I take this one?

@bnoordhuis
Copy link
Member Author

Sure, go ahead.

@jagadeeshmeesala
Copy link

jagadeeshmeesala commented Mar 10, 2023

PR is created for the documentation here #47031 #47031

Please review.

@jagadeeshmeesala
Copy link

jagadeeshmeesala commented Mar 10, 2023

I have tried to use --no-warnings=ExperimentalWarning and --no-warnings=DeprecationWarning, but it is neither accepting any of the option, basically suppressing all type of warnings. But --no-deprecation command-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) {}` 

@Lakshyachitransh
Copy link

Hi jagadeeshmeesala if you are not working on this can i take this

nodejs-github-bot pushed a commit that referenced this issue Sep 8, 2023
PR-URL: #49517
Refs: #46862
Reviewed-By: Antoine du Hamel <[email protected]>
Reviewed-By: Moshe Atlow <[email protected]>
ruyadorno pushed a commit that referenced this issue Sep 28, 2023
PR-URL: #49517
Refs: #46862
Reviewed-By: Antoine du Hamel <[email protected]>
Reviewed-By: Moshe Atlow <[email protected]>
alexfernandez pushed a commit to alexfernandez/node that referenced this issue Nov 1, 2023
PR-URL: nodejs#49517
Refs: nodejs#46862
Reviewed-By: Antoine du Hamel <[email protected]>
Reviewed-By: Moshe Atlow <[email protected]>
@Ethan-Arrowood
Copy link
Contributor

FWIW the --no-warnings flag does not accept anything. It is boolean only and will disable all warnings when enabled.

nodejs-github-bot pushed a commit that referenced this issue Nov 21, 2023
Co-authored-by: Geoffrey Booth <[email protected]>
Co-authored-by: Antoine du Hamel <[email protected]>
PR-URL: #50661
Fixes: #30810
Fixes: #47478
Fixes: #46862
Fixes: #40940
Reviewed-By: Geoffrey Booth <[email protected]>
Reviewed-By: James M Snell <[email protected]>
Reviewed-By: Benjamin Gruenbaum <[email protected]>
Reviewed-By: Vinícius Lourenço Claro Cardoso <[email protected]>
Reviewed-By: Antoine du Hamel <[email protected]>
Reviewed-By: Yagiz Nizipli <[email protected]>
Reviewed-By: Matteo Collina <[email protected]>
Reviewed-By: Richard Lau <[email protected]>
targos pushed a commit that referenced this issue Nov 23, 2023
Co-authored-by: Geoffrey Booth <[email protected]>
Co-authored-by: Antoine du Hamel <[email protected]>
PR-URL: #50661
Fixes: #30810
Fixes: #47478
Fixes: #46862
Fixes: #40940
Reviewed-By: Geoffrey Booth <[email protected]>
Reviewed-By: James M Snell <[email protected]>
Reviewed-By: Benjamin Gruenbaum <[email protected]>
Reviewed-By: Vinícius Lourenço Claro Cardoso <[email protected]>
Reviewed-By: Antoine du Hamel <[email protected]>
Reviewed-By: Yagiz Nizipli <[email protected]>
Reviewed-By: Matteo Collina <[email protected]>
Reviewed-By: Richard Lau <[email protected]>
martenrichter pushed a commit to martenrichter/node that referenced this issue Nov 26, 2023
Co-authored-by: Geoffrey Booth <[email protected]>
Co-authored-by: Antoine du Hamel <[email protected]>
PR-URL: nodejs#50661
Fixes: nodejs#30810
Fixes: nodejs#47478
Fixes: nodejs#46862
Fixes: nodejs#40940
Reviewed-By: Geoffrey Booth <[email protected]>
Reviewed-By: James M Snell <[email protected]>
Reviewed-By: Benjamin Gruenbaum <[email protected]>
Reviewed-By: Vinícius Lourenço Claro Cardoso <[email protected]>
Reviewed-By: Antoine du Hamel <[email protected]>
Reviewed-By: Yagiz Nizipli <[email protected]>
Reviewed-By: Matteo Collina <[email protected]>
Reviewed-By: Richard Lau <[email protected]>
lucshi pushed a commit to lucshi/node that referenced this issue Nov 27, 2023
Co-authored-by: Geoffrey Booth <[email protected]>
Co-authored-by: Antoine du Hamel <[email protected]>
PR-URL: nodejs#50661
Fixes: nodejs#30810
Fixes: nodejs#47478
Fixes: nodejs#46862
Fixes: nodejs#40940
Reviewed-By: Geoffrey Booth <[email protected]>
Reviewed-By: James M Snell <[email protected]>
Reviewed-By: Benjamin Gruenbaum <[email protected]>
Reviewed-By: Vinícius Lourenço Claro Cardoso <[email protected]>
Reviewed-By: Antoine du Hamel <[email protected]>
Reviewed-By: Yagiz Nizipli <[email protected]>
Reviewed-By: Matteo Collina <[email protected]>
Reviewed-By: Richard Lau <[email protected]>
RafaelGSS pushed a commit that referenced this issue Nov 29, 2023
Co-authored-by: Geoffrey Booth <[email protected]>
Co-authored-by: Antoine du Hamel <[email protected]>
PR-URL: #50661
Fixes: #30810
Fixes: #47478
Fixes: #46862
Fixes: #40940
Reviewed-By: Geoffrey Booth <[email protected]>
Reviewed-By: James M Snell <[email protected]>
Reviewed-By: Benjamin Gruenbaum <[email protected]>
Reviewed-By: Vinícius Lourenço Claro Cardoso <[email protected]>
Reviewed-By: Antoine du Hamel <[email protected]>
Reviewed-By: Yagiz Nizipli <[email protected]>
Reviewed-By: Matteo Collina <[email protected]>
Reviewed-By: Richard Lau <[email protected]>
RafaelGSS pushed a commit that referenced this issue Nov 30, 2023
Co-authored-by: Geoffrey Booth <[email protected]>
Co-authored-by: Antoine du Hamel <[email protected]>
PR-URL: #50661
Fixes: #30810
Fixes: #47478
Fixes: #46862
Fixes: #40940
Reviewed-By: Geoffrey Booth <[email protected]>
Reviewed-By: James M Snell <[email protected]>
Reviewed-By: Benjamin Gruenbaum <[email protected]>
Reviewed-By: Vinícius Lourenço Claro Cardoso <[email protected]>
Reviewed-By: Antoine du Hamel <[email protected]>
Reviewed-By: Yagiz Nizipli <[email protected]>
Reviewed-By: Matteo Collina <[email protected]>
Reviewed-By: Richard Lau <[email protected]>
UlisesGascon pushed a commit that referenced this issue Dec 11, 2023
Co-authored-by: Geoffrey Booth <[email protected]>
Co-authored-by: Antoine du Hamel <[email protected]>
PR-URL: #50661
Fixes: #30810
Fixes: #47478
Fixes: #46862
Fixes: #40940
Reviewed-By: Geoffrey Booth <[email protected]>
Reviewed-By: James M Snell <[email protected]>
Reviewed-By: Benjamin Gruenbaum <[email protected]>
Reviewed-By: Vinícius Lourenço Claro Cardoso <[email protected]>
Reviewed-By: Antoine du Hamel <[email protected]>
Reviewed-By: Yagiz Nizipli <[email protected]>
Reviewed-By: Matteo Collina <[email protected]>
Reviewed-By: Richard Lau <[email protected]>
UlisesGascon pushed a commit that referenced this issue Dec 15, 2023
Co-authored-by: Geoffrey Booth <[email protected]>
Co-authored-by: Antoine du Hamel <[email protected]>
PR-URL: #50661
Fixes: #30810
Fixes: #47478
Fixes: #46862
Fixes: #40940
Reviewed-By: Geoffrey Booth <[email protected]>
Reviewed-By: James M Snell <[email protected]>
Reviewed-By: Benjamin Gruenbaum <[email protected]>
Reviewed-By: Vinícius Lourenço Claro Cardoso <[email protected]>
Reviewed-By: Antoine du Hamel <[email protected]>
Reviewed-By: Yagiz Nizipli <[email protected]>
Reviewed-By: Matteo Collina <[email protected]>
Reviewed-By: Richard Lau <[email protected]>
UlisesGascon pushed a commit that referenced this issue Dec 19, 2023
Co-authored-by: Geoffrey Booth <[email protected]>
Co-authored-by: Antoine du Hamel <[email protected]>
PR-URL: #50661
Fixes: #30810
Fixes: #47478
Fixes: #46862
Fixes: #40940
Reviewed-By: Geoffrey Booth <[email protected]>
Reviewed-By: James M Snell <[email protected]>
Reviewed-By: Benjamin Gruenbaum <[email protected]>
Reviewed-By: Vinícius Lourenço Claro Cardoso <[email protected]>
Reviewed-By: Antoine du Hamel <[email protected]>
Reviewed-By: Yagiz Nizipli <[email protected]>
Reviewed-By: Matteo Collina <[email protected]>
Reviewed-By: Richard Lau <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
doc Issues and PRs related to the documentations. good first issue Issues that are suitable for first-time contributors.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants