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

Running initAsyncResource with a class constructor results in an abort #56356

Open
zyscoder opened this issue Dec 25, 2024 · 0 comments
Open

Comments

@zyscoder
Copy link

Version

v22.11.0

Platform

Linux u24vm 6.8.0-50-generic #51-Ubuntu SMP PREEMPT_DYNAMIC Sat Nov  9 17:58:29 UTC 2024 x86_64 x86_64 x86_64 GNU/Linux

Subsystem

async_hooks

What steps will reproduce the bug?

Setup a node instance,

» node

and run the following javascript code.

class ASYNC_HOOKS_TEST {}
async_hooks = require('async_hooks');
_38 = async_hooks.createHook({init:ASYNC_HOOKS_TEST});
_38.enable();

Then the node instance occurs an abort.

How often does it reproduce? Is there a required condition?

This abort can always be triggered following the steps above.

What is the expected behavior? Why is that the expected behavior?

If any error occurs, an exception or other similar error-reporting stuff should be thrown and then caught and handled correctly. There is no reason to abort the whole node process.

What do you see instead?

» node                                                                                                                                                                 
Welcome to Node.js v22.11.0.
Type ".help" for more information.
> 
> class ASYNC_HOOKS_TEST {
... }
undefined
> 
> async_hooks = require('async_hooks');
{
  AsyncLocalStorage: [Getter],
  createHook: [Function: createHook],
  executionAsyncId: [Function: executionAsyncId],
  triggerAsyncId: [Function: triggerAsyncId],
  executionAsyncResource: [Function: executionAsyncResource],
  asyncWrapProviders: [Object: null prototype] {
    NONE: 0,
    DIRHANDLE: 1,
    DNSCHANNEL: 2,
    ELDHISTOGRAM: 3,
    FILEHANDLE: 4,
    FILEHANDLECLOSEREQ: 5,
    BLOBREADER: 6,
    FSEVENTWRAP: 7,
    FSREQCALLBACK: 8,
    FSREQPROMISE: 9,
    GETADDRINFOREQWRAP: 10,
    GETNAMEINFOREQWRAP: 11,
    HEAPSNAPSHOT: 12,
    HTTP2SESSION: 13,
    HTTP2STREAM: 14,
    HTTP2PING: 15,
    HTTP2SETTINGS: 16,
    HTTPINCOMINGMESSAGE: 17,
    HTTPCLIENTREQUEST: 18,
    JSSTREAM: 19,
    JSUDPWRAP: 20,
    MESSAGEPORT: 21,
    PIPECONNECTWRAP: 22,
    PIPESERVERWRAP: 23,
    PIPEWRAP: 24,
    PROCESSWRAP: 25,
    PROMISE: 26,
    QUERYWRAP: 27,
    QUIC_ENDPOINT: 28,
    QUIC_LOGSTREAM: 29,
    QUIC_PACKET: 30,
    QUIC_SESSION: 31,
    QUIC_STREAM: 32,
    QUIC_UDP: 33,
    SHUTDOWNWRAP: 34,
    SIGNALWRAP: 35,
    STATWATCHER: 36,
    STREAMPIPE: 37,
    TCPCONNECTWRAP: 38,
    TCPSERVERWRAP: 39,
    TCPWRAP: 40,
    TTYWRAP: 41,
    UDPSENDWRAP: 42,
    UDPWRAP: 43,
    SIGINTWATCHDOG: 44,
    WORKER: 45,
    WORKERHEAPSNAPSHOT: 46,
    WRITEWRAP: 47,
    ZLIB: 48,
    CHECKPRIMEREQUEST: 49,
    PBKDF2REQUEST: 50,
    KEYPAIRGENREQUEST: 51,
    KEYGENREQUEST: 52,
    KEYEXPORTREQUEST: 53,
    CIPHERREQUEST: 54,
    DERIVEBITSREQUEST: 55,
    HASHREQUEST: 56,
    RANDOMBYTESREQUEST: 57,
    RANDOMPRIMEREQUEST: 58,
    SCRYPTREQUEST: 59,
    SIGNREQUEST: 60,
    TLSWRAP: 61,
    VERIFYREQUEST: 62
  },
  AsyncResource: [class AsyncResource]
}
> _38 = async_hooks.createHook({init:ASYNC_HOOKS_TEST});
AsyncHook {
  [Symbol(init)]: [class ASYNC_HOOKS_TEST],
  [Symbol(before)]: undefined,
  [Symbol(after)]: undefined,
  [Symbol(destroy)]: undefined,
  [Symbol(promiseResolve)]: undefined
}
> _38.enable();
AsyncHook {
  [Symbol(init)]: [class ASYNC_HOOKS_TEST],
  [Symbol(before)]: undefined,
  [Symbol(after)]: undefined,
  [Symbol(destroy)]: undefined,
  [Symbol(promiseResolve)]: undefined
}
> TypeError: Class constructor ASYNC_HOOKS_TEST cannot be invoked without 'new'
    at emitInitNative (node:internal/async_hooks:202:43)
    at emitInitScript (node:internal/async_hooks:505:3)
    at initAsyncResource (node:internal/timers:170:5)
    at new Timeout (node:internal/timers:204:5)
    at setTimeout (node:timers:163:19)
    at REPLServer.online (node:internal/repl/history:134:13)
    at REPLServer.emit (node:events:530:35)
    at REPLServer.emit (node:domain:489:12)
    at [_onLine] [as _onLine] (node:internal/readline/interface:415:12)
    at [_line] [as _line] (node:internal/readline/interface:886:18)

Additional information

No response

@zyscoder zyscoder changed the title Running initAsyncResource with a class constructor leads to an exception, which is not catched and results in the server's abort Running initAsyncResource with a class constructor results in an abort Dec 25, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant