Title: node:test aborts in InternalCallbackScope::Close after listen EPERM · Issue #65667 · nodejs/node · GitHub
Open Graph Title: node:test aborts in InternalCallbackScope::Close after listen EPERM · Issue #65667 · nodejs/node
X Title: node:test aborts in InternalCallbackScope::Close after listen EPERM · Issue #65667 · nodejs/node
Description: Version Reproduced with v24.20.0 and v26.7.0. Platform Linux 7.1.9-arch1-2 x86_64, glibc 2.44. Subsystem test_runner, async_hooks, platform What steps will reproduce the bug? When bind(2) returns EPERM during a node:test test, Node can a...
Open Graph Description: Version Reproduced with v24.20.0 and v26.7.0. Platform Linux 7.1.9-arch1-2 x86_64, glibc 2.44. Subsystem test_runner, async_hooks, platform What steps will reproduce the bug? When bind(2) returns E...
X Description: Version Reproduced with v24.20.0 and v26.7.0. Platform Linux 7.1.9-arch1-2 x86_64, glibc 2.44. Subsystem test_runner, async_hooks, platform What steps will reproduce the bug? When bind(2) returns E...
Opengraph URL: https://github.com/nodejs/node/issues/65667
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"node:test aborts in InternalCallbackScope::Close after listen EPERM","articleBody":"### Version\n\nReproduced with v24.20.0 and v26.7.0.\n\n### Platform\n\nLinux 7.1.9-arch1-2 x86_64, glibc 2.44.\n\n### Subsystem\n\ntest_runner, async_hooks, platform\n\n### What steps will reproduce the bug?\n\nWhen `bind(2)` returns `EPERM` during a `node:test` test, Node can abort in `InternalCallbackScope::Close()` instead of reporting the listen error. The larger JS body appears to matter for timing. A much smaller `server.listen()` test reports `listen EPERM` normally.\n\nSave this as `deny-bind.c`:\n\n```c\n#define _GNU_SOURCE\n#include \u003cerrno.h>\n#include \u003csys/socket.h>\n\nint bind(int socket, const struct sockaddr *address, socklen_t address_len) {\n errno = EPERM;\n return -1;\n}\n```\n\nSave this as `repro.mjs`:\n\n```js\nimport { test } from 'node:test';\nimport assert from 'node:assert/strict';\nimport { randomUUID } from 'node:crypto';\nimport { mkdtemp, readFile, rm } from 'node:fs/promises';\nimport { join } from 'node:path';\nimport { tmpdir } from 'node:os';\nimport { createServer } from 'node:http';\nimport { spawn } from 'node:child_process';\n\nconst sourceId = randomUUID();\nconst stamp = '2026-08-30T12:00:00.000Z';\nconst item = { id: randomUUID(), version: 1, title: 'x', description: '', expected: '', steps: '', actual: '', evidence: '', author: '', team: '', area: '', feature: '', pagePath: '/reports', kind: 'issue', impact: 'high', status: 'new', priority: 'unassigned', owner: '', resolution: '', release: 'test', browser: '', viewport: '', createdAt: stamp, updatedAt: stamp, comments: [], history: [] };\nconst envelope = (changes = [{ sequence: 1, item }], overrides = {}) => ({ schemaVersion: 1, mode: 'changes', sourceId, after: 0, nextCursor: 1, hasMore: false, exportedAt: stamp, changes, ...overrides });\n\nfunction run(args, token = 'test-key'.padEnd(40, 'x')) {\n return new Promise((resolve) => {\n const child = spawn(process.execPath, ['-e', 'process.exit(0)', ...args], {\n env: { ...process.env, FEEDBACK_SYNC_TOKEN: token, FEEDBACK_REMOTE_URL: '' },\n });\n let output = '';\n child.stdout.on('data', (b) => { output += b; });\n child.stderr.on('data', (b) => { output += b; });\n child.on('close', (code) => resolve({ code, output }));\n });\n}\n\ntest('reproducer', async () => {\n const directory = await mkdtemp(join(tmpdir(), 'feedback-cli-'));\n let failSecond = true;\n let redirect = false;\n const server = createServer((request, response) => {\n if (redirect) { response.writeHead(302, { location: 'https://example.com' }); response.end(); return; }\n const after = Number(new URL(request.url, 'http://localhost').searchParams.get('after'));\n if (after === 1 && failSecond) { response.writeHead(503); response.end(); return; }\n response.setHeader('content-type', 'application/json');\n response.end(JSON.stringify(after === 0 ? envelope(undefined, { hasMore: true }) : after === 1 ? envelope([{ sequence: 2, item: { ...item, version: 2, status: 'planned' } }], { after: 1, nextCursor: 2 }) : envelope([], { after: 2, nextCursor: 2 })));\n });\n await new Promise((resolve) => server.listen(0, '127.0.0.1', resolve));\n const url = `http://127.0.0.1:${server.address().port}`;\n const args = ['--url', url, '--allow-http', '--out', directory];\n try {\n assert.equal((await run(['--url', url, '--out', directory])).code, 1);\n assert.equal((await run(args)).code, 1);\n assert.equal(JSON.parse(await readFile(join(directory, 'feedback.json'))).cursor, 1);\n failSecond = false;\n assert.equal((await run(args)).code, 0);\n assert.equal((await run(args)).code, 0);\n redirect = true;\n assert.equal((await run(args)).code, 1);\n } finally {\n await new Promise((resolve) => server.close(resolve));\n await rm(directory, { recursive: true, force: true });\n }\n});\n```\n\nCompile the interceptor and run the test:\n\n```bash\ncc -shared -fPIC -o deny-bind.so deny-bind.c\nLD_PRELOAD=\"$PWD/deny-bind.so\" node --test --test-isolation=none repro.mjs\n```\n\nThis reproduced on every attempted run with both listed Node versions. It also occurs with the default process isolation, where the test child aborts and the parent reports a failed test.\n\n### How often does it reproduce? Is there a required condition?\n\nEvery run with the reproducer above on this machine. `bind()` must fail with `EPERM`. The original occurrence was inside a restricted environment where loopback binding was denied. When binding is permitted, the same test passes.\n\n### What is the expected behavior? Why is that the expected behavior?\n\nThe test runner should report `Error: listen EPERM: operation not permitted 127.0.0.1` and exit with a normal test failure. A smaller `server.listen()` test under the same interceptor already behaves this way.\n\n### What do you see instead?\n\nThe process aborts with exit status 134:\n\n```text\nAssertion failed: (env_->execution_async_id()) == (0)\n\n1: node::Assert(node::AssertionInfo const&)\n2: node::InternalCallbackScope::Close()\n3: node::InternalCallbackScope::~InternalCallbackScope()\n4: node::PerIsolatePlatformData::RunForegroundTask(...)\n5: node::PerIsolatePlatformData::FlushForegroundTasksInternal()\n6: uv_run\n7: node::SpinEventLoopInternal(node::Environment*)\n8: node::NodeMainInstance::Run()\n9: node::Start(int, char**)\n```\n\nOn v24.20.0 the assertion is at `src/api/callback.cc:165`; on v26.7.0 it is at line 185.\n\n### Additional information\n\nThis may be related to #38155, but that older case involved `async-hook-domain` monkey-patching. This reproducer uses only built-in Node modules and the test runner.\n\nNo core dump is attached because cores may contain private process memory.\n","author":{"url":"https://github.com/Fuucodi0X","@type":"Person","name":"Fuucodi0X"},"datePublished":"2026-08-30T14:34:11Z","url":"https://github.com/nodejs/node/issues/65667"}
| react-profiling | 0 |
| react-import-map | react,react-dom,react-dom/client,react-dom/profiling,react-is,react-reconciler,react/compiler-runtime,react/jsx-dev-runtime,react/jsx-runtime,scheduler@d5750093facf |
| route-pattern | /_view_fragments/issues/show/:user_id/:repository/:id/issue_layout(.:format) |
| route-controller | voltron_issues_fragments |
| route-action | issue_layout |
| fetch-nonce | v2:a0e0c6a0-ed3e-96bb-e98e-83b90ddbb055 |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | C990:1A50E8:97776:CDCF7:6AED32F0 |
| html-safe-nonce | 59e26bdee87f4b5f3aeb9ee8c3b0a4436f8e000c1fe0aa0771e0e6c5ce4ccc05 |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJDOTkwOjFBNTBFODo5Nzc3NjpDRENGNzo2QUVEMzJGMCIsInZpc2l0b3JfaWQiOiI2NjU0NjU5NDQ0NTM0MTQyNCIsInJlZ2lvbl9lZGdlIjoiaWFkIiwicmVnaW9uX3JlbmRlciI6ImlhZCJ9 |
| visitor-hmac | 41bdcb8406d089ee8c2b7f407a152403f435e457d790206b98597f4eeeda80c1 |
| hovercard-subject-tag | issue:5292604008 |
| github-keyboard-shortcuts | repository,issues,copilot |
| google-site-verification | Apib7-x98H0j5cPqHWwSMm6dNU4GmODRoqxLiDzdx9I |
| octolytics-url | https://collector.github.com/github/collect |
| analytics-location | / |
| fb:app_id | 1401488693436528 |
| apple-itunes-app | app-id=1477376905, app-argument=https://github.com/_view_fragments/issues/show/nodejs/node/65667/issue_layout |
| twitter:image | https://opengraph.githubassets.com/3d4286b95d2ee99e37ded7791002b3b53cd35caac459633db8d69ae6137be5ac/nodejs/node/issues/65667 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/3d4286b95d2ee99e37ded7791002b3b53cd35caac459633db8d69ae6137be5ac/nodejs/node/issues/65667 |
| og:image:alt | Version Reproduced with v24.20.0 and v26.7.0. Platform Linux 7.1.9-arch1-2 x86_64, glibc 2.44. Subsystem test_runner, async_hooks, platform What steps will reproduce the bug? When bind(2) returns E... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | Fuucodi0X |
| hostname | github.com |
| expected-hostname | github.com |
| None | 26c92a9388ddfad3fa88d132b5d5f0b4747030233dcc4e5efb05f1cbae152184 |
| turbo-cache-control | no-preview |
| go-import | github.com/nodejs/node git https://github.com/nodejs/node.git |
| octolytics-dimension-user_id | 9950313 |
| octolytics-dimension-user_login | nodejs |
| octolytics-dimension-repository_id | 27193779 |
| octolytics-dimension-repository_nwo | nodejs/node |
| octolytics-dimension-repository_public | true |
| octolytics-dimension-repository_is_fork | false |
| octolytics-dimension-repository_network_root_id | 27193779 |
| octolytics-dimension-repository_network_root_nwo | nodejs/node |
| turbo-body-classes | logged-out env-production page-responsive |
| disable-turbo | false |
| browser-stats-url | https://api.github.com/_private/browser/stats |
| browser-errors-url | https://api.github.com/_private/browser/errors |
| release | c629ad99c254d306375fc8354d04321c2c362236 |
| ui-target | canary-1 |
| theme-color | #1e2327 |
| color-scheme | light dark |
| react-app-name | issues |
Links:
Viewport: width=device-width