Repository navigation
Conversation
Running as the image CMD has two problems: the Actor's real start command is lost (the entrypoint is guessed from package.json/conventional paths), and an ENTRYPOINT defined in the Actor's own Dockerfile silently swallows our CMD, so the Actor runs with no debugger and no error. As ENTRYPOINT, Docker appends the image's own CMD to our arguments. Everything after --brk is now treated as that start command and resolved into a Node.js launch spec, keeping the original node flags and script arguments: node [flags] <script> [args] -> that script, flags and args preserved npm|pnpm|yarn [run] <script> -> the package.json script, parsed again sh -c "<command>" -> the inner command, parsed again <path> -> that file (the explicit-path form) Chained scripts are resolved from the last segment back, so `npm run build && node dist/main.js` debugs the Actor, not the build step. With no command passed, the previous auto-detection still applies, so the existing CMD forms keep working unchanged. When a command is passed but no Node.js entrypoint can be derived from it, the debugger fails fast with the reason instead of starting the Actor undebuggable. Adds a node:test suite for the resolver (no new dependencies) and runs it, plus a syntax check of the new module, in the release workflow. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01UTxccb4QARxDG34guZbeFG
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Why
Running the debugger as the image
CMDhas two problems:package.jsonscripts.start/main/ conventional paths, so Node flags (--max-old-space-size,-r ...) and script arguments never reached the Actor.ENTRYPOINTin the Actor's own Dockerfile silently swallows ourCMD. Docker then runs that entrypoint with["npx", "actor-debugger", "--brk"]as arguments — the Actor starts with no debugger attached and no error anywhere.This matters for the planned Console "Debug" option, which appends the debug layer to an arbitrary user Dockerfile: it cannot know whether that Dockerfile defines an
ENTRYPOINT, and it cannot guess the Actor's start command.What changed
ENTRYPOINT ["actor-debugger", "--brk"]is now the recommended form. Docker appends the image's ownCMDto our arguments, so everything after--brkis treated as the Actor's start command and resolved into a Node.js launch spec, preserving the original flags and arguments:node [flags] <script> [args]-r x/--import x) and argsnpm start,npm run <s>,pnpm …,yarn …package.jsonscript, parsed againsh -c "<command>"dist/main.jsChained commands are split on
&&/||/;/|and tried from the last segment back, sonpm run build && node dist/main.jsdebugsdist/main.jsrather than the build step. Resolution recurses up to 4 levels (annpm startthat itself callssh -c, and so on).With no command passed (the old
CMD ["npx", "actor-debugger"]form) the previous auto-detection is unchanged, so existing Dockerfiles keep working.If a command is passed but no Node.js entrypoint can be derived from it (e.g. a
tsx/ts-nodelauncher), the debugger now fails fast with the reason instead of starting the Actor undebugged — a run you asked to debug should not silently run without a debugger. The message points at the explicit form:ENTRYPOINT ["actor-debugger", "--brk", "dist/main.js"].Files
lib/resolve_launch.mjs(new) — quote-aware tokenizer +resolveLaunch()returning{ entry, nodeFlags, scriptArgs, source }.bin/cli.mjs— treats non---brkargv as the start command, passes the resolved flags/args through to the spawnednode, exits 1 with the reason when unresolvable.test/resolve_launch.test.mjs(new) — 18node:testcases against real temp directories.package.json—npm testscript (node --test test/*.test.mjs)..github/workflows/publish.yml— syntax-check the new module and runnpm testbefore publishing.README.md— ENTRYPOINT-first snippet and the rewritten detection order.Verified
npm test→ 18/18 pass. Manual smoke tests of every form against a real temp Actor, asserting bothprocess.argvand that--inspectis inprocess.execArgv:npm start(→node dist/main.js --from-cmd) — argv and inspector correct, exit 0sh -c "echo building && node dist/main.js --chained"— resolves the last segment, exit 0dist/main.js(explicit) and no-argument auto-detect — both exit 0tsx src/main.ts— exits 1 withunrecognized start command, as intended🤖 Generated with Claude Code
https://claude.ai/code/session_01UTxccb4QARxDG34guZbeFG
Generated by Claude Code