[BUG] "Error executing Claude query: Claude Code process exited with code 1" when executing using Typescript Claude Code SDK in VSCode Typescript debug terminal
Resolved 💬 19 comments Opened Jul 28, 2025 by monarchwadia Closed Feb 11, 2026
Environment
- Platform (select one):
- [x] Anthropic API
- [ ] AWS Bedrock
- [ ] Google Vertex AI
- [ ] Other: <!-- specify -->
- Claude CLI version: 1.0.61 (Claude Code)
- Operating System: Using Devcontainer
mcr.microsoft.com/devcontainers/typescript-node:1-22-bookwormwhich usesDebian GNU/Linux 12 (bookworm) - Terminal: bash
Bug Description
Claude Code SDK runs just fine when running in a regular, non-debug shell with no debugger attached (kudos on job well done)
However, when running in Typescript debug console, it fails with Error executing Claude query: Claude Code process exited with code 1" when executing using Typescript Claude Code SDK and a non-useful stack trace.
Expected behaviour
Should run when debugging in VSCode
If it fails, should show useful error
Actual behaviour
Does not run when debugging in VSCode
When it fails, does not show useful error
Additional Context
# i run using `pnpm dev`
"dev": "pnpm dev:client & pnpm dev:server & wait",
"dev:client": "vite serve src/client --host",
"dev:server": "tsx --env-file=.env --watch src/server/server.ts",
<img width="235" height="72" alt="Image" src="https://github.com/user-attachments/assets/b85dae61-9b01-4e17-aabb-8e2786a5ee2d" />
<img width="732" height="380" alt="Image" src="https://github.com/user-attachments/assets/3f39862e-2804-4610-9e60-faac9a2f39b2" />
# Start of VSCode launch, right after I hit the green "Start" button on the topleft of my VSCode GUI
node ➜ /workspaces/meadowmerge/prototype (main) $ cd /workspaces/meadowmerge/prototype ; /usr/bin/env 'NODE_OPTIONS= --require /vscode/vscode-server/bin/linux-x64/c306e94f98122556ca081f527b466015e1bc37b0/extensions/ms-vscode.js-debug/src/bootloader.js --inspect-publish-uid=http' 'VSCODE_INSPECTOR_OPTIONS=:::{"inspectorIpc":"/tmp/node-cdp.84878-dabaa516-302.sock","deferredMode":false,"waitForDebugger":"","execPath":"/usr/local/bin/node","onlyEntrypoint":false,"autoAttachMode":"always","mandatePortTracking":true,"fileCallback":"/tmp/node-debug-callback-6637f01801d08b61"}' /usr/local/share/npm-global/bin/pnpm dev
Debugger attached.
Debugger attached.
> @meadowmerge/prototype@1.0.0 dev /workspaces/meadowmerge/prototype
> pnpm dev:client & pnpm dev:server & wait
Debugger attached.
Debugger attached.
> @meadowmerge/prototype@1.0.0 dev:server /workspaces/meadowmerge/prototype
> tsx --env-file=.env --watch src/server/server.ts
> @meadowmerge/prototype@1.0.0 dev:client /workspaces/meadowmerge/prototype
> vite serve src/client --host
Debugger attached.
Debugger attached.
Debugger attached.
VITE v7.0.6 ready in 1132 ms
➜ Local: http://localhost:5173/
➜ Network: http://172.17.0.2:5173/
Server is running on http://localhost:3001
ANTHROPIC_API_KEY: <REDACTED, is present>
Current working directory: /tmp/git-clone-nPm5IW
Claude query response received.
Debugger attached.
Waiting for the debugger to disconnect...
Error executing Claude query: Claude Code process exited with code 1
Error: Claude Code process exited with code 1
at ChildProcess.<anonymous> (/workspaces/meadowmerge/node_modules/.pnpm/@anthropic-ai+claude-code@1.0.61/node_modules/@anthropic-ai/claude-code/sdk.mjs:224:25)
at ChildProcess.emit (node:events:518:28)
at maybeClose (node:internal/child_process:1101:16)
at Socket.<anonymous> (node:internal/child_process:456:11)
at Socket.emit (node:events:518:28)
at Pipe.<anonymous> (node:net:351:12)
at Pipe.callbackTrampoline (node:internal/async_hooks:130:17)
Error generating AI accomplishments report: Error: Claude Code process exited with code 1
at ChildProcess.<anonymous> (/workspaces/meadowmerge/node_modules/.pnpm/@anthropic-ai+claude-code@1.0.61/node_modules/@anthropic-ai/claude-code/sdk.mjs:224:25)
at ChildProcess.emit (node:events:518:28)
at maybeClose (node:internal/child_process:1101:16)
at Socket.<anonymous> (node:internal/child_process:456:11)
at Socket.emit (node:events:518:28)
at Pipe.<anonymous> (node:net:351:12)
at Pipe.callbackTrampoline (node:internal/async_hooks:130:17)
/*! 🌼 daisyUI 5.0.47 */
19 Comments
+1
+1
+1
+1
Summarized by claude itself:
Fix for VSCode Debugger Issue with Claude Code SDK
Problem
When running the Claude Code SDK in VSCode's debug mode, the subprocess crashes with exit code 1. This is caused by VSCode's auto-attach feature injecting debugger environment variables that interfere with the Claude subprocess.
Root Cause
VSCode injects these environment variables:
NODE_OPTIONS- Contains debugger bootstrap codeVSCODE_INSPECTOR_OPTIONS- Contains debugger configurationThese are inherited by the Claude subprocess, causing it to try to attach to the debugger and crash.
Solution
When using the Claude Code SDK, clean the environment variables before passing them to the
queryfunction:Why This Works
Thanks. To be honest, this is very common for development flows, so it should be handled by the SDK, not by client code. At the very least, SDK should throw a useful validation error on startup, with clear steps or a link to docs for how to handle.
I'm having the same issue without using VSCode.
Could the SDK at least provide relevant debugging information? My
stderrhandler is just receiving the stack traceWorkaround for me, just downgraded node from 24 to 22 vrsion and done!
Anyone know how to explain this to a newbie?
It seems that if you don't accept the last terms of service this error can happen too.
This worked for me.
Same problem. Downgraded node from 25 to 22 version and works.
FYI - setting DEBUG=1 in the environment is really helpful in debugging issues like this. In my case I was trying to stream inputs into the query() function and the Claude SDK subprocess was failing silently. With DEBUG=1 I was able to see some error output.
In my case after setting
DEBUGtrue I saw I was using the root user. Creating a new user fixed it.Why isn't the actual error msg in the output by default?
This issue has been inactive for 30 days. If the issue is still occurring, please comment to let us know. Otherwise, this issue will be automatically closed in 30 days for housekeeping purposes.
Ran into this with @anthropic-ai/claude-agent-sdk, v0.2.4
In my case it was caused by passing an invalid session ID to resume. No error logged even with Debug set
This issue has been automatically closed due to 60 days of inactivity. If you're still experiencing this issue, please open a new issue with updated information.
This issue was closed incorrectly despite recent human comments. This behavior of the bot is reported at https://github.com/anthropics/claude-code/issues/16497. Please upvote that issue, so maybe it gets noticed.
This issue has been automatically locked since it was closed and has not had any activity for 7 days. If you're experiencing a similar issue, please file a new issue and reference this one if it's relevant.