-
-
Notifications
You must be signed in to change notification settings - Fork 32.3k
Open
Description
Version
Node.js v25.0.0-pre
Platform
Darwin ??? 24.5.0 Darwin Kernel Version 24.5.0: Tue Apr 22 19:53:27 PDT 2025; root:xnu-11417.121.6~2/RELEASE_ARM64_T6041 arm64
Subsystem
fs
What steps will reproduce the bug?
import worker_threads from 'node:worker_threads'
import fs from 'node:fs/promises'
import { fileURLToPath } from 'node:url'
const __dirname = fileURLToPath(import.meta.url)
if (worker_threads.isMainThread) {
const w = new worker_threads.Worker(__dirname);
w.on('message', async (fh) => {
const c = await fh.read()
console.log('dir contents (from main):', c)
})
} else {
const fh = await fs.open(__dirname)
worker_threads.parentPort.postMessage(fh, [fh])
await fh.read()
}
How often does it reproduce? Is there a required condition?
everytime
What is the expected behavior? Why is that the expected behavior?
the error should't be file closed
, but something like file has benn transfered
.
What do you see instead?
node git:(main) ✗ out/Debug/node ./test.js
dir contents (from main): [Object: null prototype] {
bytesRead: 493,
buffer: <Buffer 69 6d 70 6f 72 74 20 77 6f 72 6b 65 72 5f 74 68 72 65 61 64 73 20 66 72 6f 6d 20 27 6e 6f 64 65 3a 77 6f 72 6b 65 72 5f 74 68 72 65 61 64 73 27 0a 69 ... 16334 more bytes>
}
node:internal/event_target:1101
process.nextTick(() => { throw err; });
^
Error: file closed
at fsCall (node:internal/fs/promises:458:17)
at FileHandle.read (node:internal/fs/promises:198:12)
at file:///Users/himself65/Code/node/test.js:15:12 {
code: 'EBADF',
syscall: 'read'
}
Node.js v25.0.0-pre
Additional information
No response
Metadata
Metadata
Assignees
Labels
No labels