Skip to content

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

Description

@bnoordhuis

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.

Activity

  1. added
    docIssues and PRs related to Node.js documentation.
    good first issueIssues that are suitable for first-time contributors.
    on Feb 27, 2023
  2. jakecastelli commented on Feb 27, 2023

    @jakecastelli
    Member

    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.

  3. bnoordhuis commented on Feb 28, 2023

    @bnoordhuis
    MemberAuthor

    --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.

  4. jakecastelli commented on Feb 28, 2023

    @jakecastelli
    Member

    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!

  5. bnoordhuis commented on Mar 1, 2023

    @bnoordhuis
    MemberAuthor

    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.

  6. jakecastelli commented on Mar 1, 2023

    @jakecastelli
    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 :(

  7. jagadeeshmeesala commented on Mar 8, 2023

    @jagadeeshmeesala

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

  8. bnoordhuis commented on Mar 8, 2023

    @bnoordhuis
    MemberAuthor

    Sure, go ahead.

  9. jagadeeshmeesala commented on Mar 10, 2023

    @jagadeeshmeesala

    PR is created for the documentation here #47031 #47031

    Please review.

  10. jagadeeshmeesala commented on Mar 10, 2023

    @jagadeeshmeesala

    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) {}` 
    
  11. Lakshyachitransh commented on May 2, 2023

    @Lakshyachitransh

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

  12. Ethan-Arrowood commented on Nov 10, 2023

    @Ethan-Arrowood
    Contributor

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

  13. added a commit that references this issue on Nov 23, 2023
  14. added a commit that references this issue on Nov 27, 2023
  15. added 2 commits that reference this issue on Nov 29, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    docIssues and PRs related to Node.js documentation.good first issueIssues that are suitable for first-time contributors.

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions