Skip to content

"Maximum call stack size exceeded" causes a crash in "async_hooks" module #37989

Open
@zyscoder

Description

@zyscoder

What steps will reproduce the bug?

Setup a node instance,

» node

and run the following javascript code.

async_hooks.createHook({after:new async_hooks.AsyncResource('str').bind(()=>{})}).enable();

Then the node instance crashes.

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?

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

What do you see instead?

» node
Welcome to Node.js v14.15.1.
Type ".help" for more information.
> async_hooks.createHook({after:new async_hooks.AsyncResource('str').bind(()=>{})}).enable();
AsyncHook {
  [Symbol(init)]: undefined,
  [Symbol(before)]: undefined,
  [Symbol(after)]: [Function: bound runInAsyncScope] {
    asyncResource: AsyncResource {
      [Symbol(async_id_symbol)]: 26,
      [Symbol(trigger_async_id_symbol)]: 5,
      [Symbol(destroyed)]: [Object]
    }
  },
  [Symbol(destroy)]: undefined,
  [Symbol(promiseResolve)]: undefined
}
> RangeError: Maximum call stack size exceeded
    at process._rawDebug (internal/process/per_thread.js:53:30)
    at fatalError (internal/async_hooks.js:159:13)
    at emitHook (internal/async_hooks.js:234:5)
    at emitAfterScript (internal/async_hooks.js:480:5)
    at AsyncResource.runInAsyncScope (async_hooks.js:198:9)
    at emitHook (internal/async_hooks.js:230:38)
    at emitAfterScript (internal/async_hooks.js:480:5)
    at AsyncResource.runInAsyncScope (async_hooks.js:198:9)
    at emitHook (internal/async_hooks.js:230:38)
    at emitAfterScript (internal/async_hooks.js:480:5)                                                                                                                                                                                                                                           

Additional information

Metadata

Metadata

Assignees

No one assigned

    Labels

    async_hooksIssues and PRs related to the async hooks subsystem.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions