This repository was archived by the owner on Nov 2, 2025. It is now read-only.
-
-
Notifications
You must be signed in to change notification settings - Fork 12
This repository was archived by the owner on Nov 2, 2025. It is now read-only.
Node.js crashes with native stack trace if throwing inside of an async function #53
Copy link
Copy link
Open
Description
This code crashes the Node.js process with a native stack trace (libtap@1.4.1):
const { test } = require('libtap')
test(() => {
(async () => {
throw new Error('foo')
})()
})This code doesn't crash with a native stack trace (notice the difference of the removed async symbol):
const { test } = require('libtap')
test(() => {
(() => {
throw new Error('foo')
})()
})Expand to see stack trace
TAP version 13
# Subtest
not ok 1 - foo
---
stack: |
bar.js:5:11
Test.<anonymous> (bar.js:6:5)
Test.cb (node_modules/libtap/lib/test.js:127:40)
node_modules/libtap/lib/test.js:369:21
Test.main (node_modules/libtap/lib/test.js:376:7)
Test.runMain (node_modules/libtap/lib/base.js:178:15)
node_modules/libtap/lib/test.js:490:13
TAP.writeSubComment (node_modules/libtap/lib/test.js:561:5)
at:
line: 5
column: 11
file: bar.js
tapCaught: unhandledRejection
source: |2
(async () => {
throw new Error('foo')
----------^
})()
})
...
1..1
# failed 1 test
not ok 1 # time=7.715ms
# node[53005]: void node::InternalCallbackScope::Close() at ../src/api/callback.cc:145
# Assertion failed: (env_->execution_async_id()) == (0)
----- Native stack trace -----
1: 0x104de8404 node::Assert(node::AssertionInfo const&) [/Users/thomas.watson/.nvm/versions/node/v22.4.1/bin/node]
2: 0x1069c5d14 node::InternalCallbackScope::Close() (.cold.2) [/Users/thomas.watson/.nvm/versions/node/v22.4.1/bin/node]
3: 0x104d0cda4 node::InternalCallbackScope::Close() [/Users/thomas.watson/.nvm/versions/node/v22.4.1/bin/node]
4: 0x104d0c7bc node::InternalCallbackScope::~InternalCallbackScope() [/Users/thomas.watson/.nvm/versions/node/v22.4.1/bin/node]
5: 0x104e50470 node::PerIsolatePlatformData::RunForegroundTask(std::__1::unique_ptr<v8::Task, std::__1::default_delete<v8::Task>>) [/Users/thomas.watson/.nvm/versions/node/v22.4.1/bin/node]
6: 0x104e4f1c0 node::PerIsolatePlatformData::FlushForegroundTasksInternal() [/Users/thomas.watson/.nvm/versions/node/v22.4.1/bin/node]
7: 0x104e50728 node::NodePlatform::DrainTasks(v8::Isolate*) [/Users/thomas.watson/.nvm/versions/node/v22.4.1/bin/node]
8: 0x104d0d730 node::SpinEventLoopInternal(node::Environment*) [/Users/thomas.watson/.nvm/versions/node/v22.4.1/bin/node]
9: 0x104e29cc8 node::NodeMainInstance::Run(node::ExitCode*, node::Environment*) [/Users/thomas.watson/.nvm/versions/node/v22.4.1/bin/node]
10: 0x104e299dc node::NodeMainInstance::Run() [/Users/thomas.watson/.nvm/versions/node/v22.4.1/bin/node]
11: 0x104db0590 node::Start(int, char**) [/Users/thomas.watson/.nvm/versions/node/v22.4.1/bin/node]
12: 0x1879460e0 start [/usr/lib/dyld]
[1] 53005 abort node bar.js
Metadata
Metadata
Assignees
Labels
No labels