The issue involves debugging-specific behavior and async error handling.
The issue occurs when using `console.log` in a Visual Studio Code debugging session on Linux, resulting in an EBADF error. The problem appears to be related to async error handling in the debug environment. While the maintainer has identified a potential fix, implementing it requires understanding Node.js internals and debugging environments.
v22.21.1
Linux mandolin 6.17.0-8-generic #8-Ubuntu SMP PREEMPT_DYNAMIC Fri Nov 14 21:44:46 UTC 2025 x86_64 GNU/Linux
No response
In this case the error occurs when attempting to scan the metadata of a postgresql database (iterating over tables), where I get output on the first table but an error on the second. The actual line of code erroring here is " console.log(metadata: ${rows});"
This code works on windows under visual studio code and it works on linux run from a separate terminal.
Uncaught Error Error: EBADF: bad file descriptor, write at writeSync (<node_internals>/fs:923:3) at SyncWriteStream._write (<node_internals>/internal/fs/sync_write_stream:27:5) at writeOrBuffer (<node_internals>/internal/streams/writable:572:12) at _write (<node_internals>/internal/streams/writable:501:10) at Writable.write (<node_internals>/internal/streams/writable:510:10) at value (<node_internals>/internal/console/constructor:298:16) at log (<node_internals>/internal/console/constructor:384:26) at sanityCheckDB (/home/ulmont/git-repos/get-uscf-td-record/databaseUtilities.js:369:13) at processTicksAndRejections (<node_internals>/internal/process/task_queues:105:5) --- TickObject --- at init (<node_internals>/internal/inspector_async_hook:19:17) at emitInitNative (<node_internals>/internal/async_hooks:206:43) at emitInitScript (<node_internals>/internal/async_hooks:513:3) at nextTick (<node_internals>/internal/process/task_queues:143:5) at onDestroy (<node_internals>/internal/streams/destroy:116:15) at dummyDestroy (<node_internals>/internal/bootstrap/switches/is_main_thread:115:3) at _destroy (<node_internals>/internal/streams/destroy:122:10) at destroy (<node_internals>/internal/streams/destroy:84:5) at Writable.destroy (<node_internals>/internal/streams/writable:1122:11) at errorOrDestroy (<node_internals>/internal/streams/destroy:225:12) at onwriteError (<node_internals>/i
Claim this issue to let others know you're working on it. You'll earn 10 points when you complete it!