Skip to content

Node console.log reporting EBADF on linux in a Visual Studio Code debugging session #61289

@ulmont

Description

@ulmont

Version

v22.21.1

Platform

Linux mandolin 6.17.0-8-generic #8-Ubuntu SMP PREEMPT_DYNAMIC Fri Nov 14 21:44:46 UTC 2025 x86_64 GNU/Linux

Subsystem

No response

What steps will reproduce the bug?

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>/internal/streams/writable:612:3)
at processTicksAndRejections (<node_internals>/internal/process/task_queues:92:21)
--- 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 onwrite (<node_internals>/internal/streams/writable:647:15)
at SyncWriteStream._write (<node_internals>/internal/fs/sync_write_stream:29: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)
--- await ---
at initDB (/home/ulmont/git-repos/get-uscf-td-record/databaseUtilities.js:58:9)
at (/home/ulmont/git-repos/get-uscf-td-record/useful-USCF-stuff.js:12:18)
at run (<node_internals>/internal/modules/esm/module_job:343:25)
at processTicksAndRejections (<node_internals>/internal/process/task_queues:105:5)
--- await ---
at onImport.tracePromise.proto (<node_internals>/internal/modules/esm/loader:665:42)
at processTicksAndRejections (<node_internals>/internal/process/task_queues:105:5)
--- await ---
at tracePromise (<node_internals>/diagnostics_channel:350:14)
at import (<node_internals>/internal/modules/esm/loader:663:21)
at (<node_internals>/internal/modules/run_main:179:35)
at asyncRunEntryPointWithESMLoader (<node_internals>/internal/modules/run_main:117:11)
at runEntryPointWithESMLoader (<node_internals>/internal/modules/run_main:139:19)
at executeUserEntryPoint (<node_internals>/internal/modules/run_main:176:5)
at (<node_internals>/internal/main/run_main_module:36:49)

VS Code version: Code 1.107.1 (microsoft/vscode@994fd12, 2025-12-17T14:15:14.850Z)
OS version: Linux x64 6.17.0-8-generic

How often does it reproduce? Is there a required condition?

In this environment on linux in visual code it's 100% reproduceable; I haven't been able to generate a small test example.

What is the expected behavior? Why is that the expected behavior?

The expected behavior is not to error out on a console log call.

What do you see instead?

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>/internal/streams/writable:612:3)
at processTicksAndRejections (<node_internals>/internal/process/task_queues:92:21)
--- 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 onwrite (<node_internals>/internal/streams/writable:647:15)
at SyncWriteStream._write (<node_internals>/internal/fs/sync_write_stream:29: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)
--- await ---
at initDB (/home/ulmont/git-repos/get-uscf-td-record/databaseUtilities.js:58:9)
at (/home/ulmont/git-repos/get-uscf-td-record/useful-USCF-stuff.js:12:18)
at run (<node_internals>/internal/modules/esm/module_job:343:25)
at processTicksAndRejections (<node_internals>/internal/process/task_queues:105:5)
--- await ---
at onImport.tracePromise.proto (<node_internals>/internal/modules/esm/loader:665:42)
at processTicksAndRejections (<node_internals>/internal/process/task_queues:105:5)
--- await ---
at tracePromise (<node_internals>/diagnostics_channel:350:14)
at import (<node_internals>/internal/modules/esm/loader:663:21)
at (<node_internals>/internal/modules/run_main:179:35)
at asyncRunEntryPointWithESMLoader (<node_internals>/internal/modules/run_main:117:11)
at runEntryPointWithESMLoader (<node_internals>/internal/modules/run_main:139:19)
at executeUserEntryPoint (<node_internals>/internal/modules/run_main:176:5)
at (<node_internals>/internal/main/run_main_module:36:49)

VS Code version: Code 1.107.1 (microsoft/vscode@994fd12, 2025-12-17T14:15:14.850Z)
OS version: Linux x64 6.17.0-8-generic

Additional information

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions