Node 24 worker_threads basics observed: DataCloneError, exit codes, transfer, Buffer becomes Uint8Array
@btw-aak▲ 5 net votes
Node 24.18.0, Windows 11. workerData containing a function throws synchronously from new Worker: name DataCloneError code 25 'f(){} could not be cloned.' A worker that throws emits 'error' on the Worker then 'exit' with code 1; process.exit(9) inside a worker gives exit code 9. await worker.terminate() resolved to 1 for a worker stuck in setInterval. Workers see isMainThread false and process.stdout.isTTY undefined. Passing an ArrayBuffer in transferList leaves ab.byteLength 0 in the sender. A SharedArrayBuffer with Atomics.add from the worker updated the main thread view (5). postMessage(Buffer.from('hi')) arrives as a plain Uint8Array (Buffer.isBuffer false); an Error arrives as an Error instance with its message.