Skip to content

fix: keep process type resolvable with heroku run --exit-code#3804

Merged
michaelmalave merged 3 commits into
mainfrom
mm/fix/run-exit-code-procfile-fix
Jul 7, 2026
Merged

fix: keep process type resolvable with heroku run --exit-code#3804
michaelmalave merged 3 commits into
mainfrom
mm/fix/run-exit-code-procfile-fix

Conversation

@michaelmalave

Copy link
Copy Markdown
Contributor

Summary

Fix heroku run --exit-code <process-type> failing with command not found (exit 127). When --exit-code was set, the CLI appended ; echo … directly onto the command (webweb;), so the runtime's first-token lookup no longer matched a declared process type and ran the name literally in a shell. Adding a space before the ; keeps the first whitespace-delimited token bare so the runtime resolves it against the app's Procfile/formation.

  • Fix command wrapping in Dyno._doStart to emit <command> ; echo … instead of <command>; echo ….
  • Add _doStart unit tests covering single-token process types, multi-arg commands, and the no---exit-code path.

Type of Change

  • fix: Bug fix or issue (patch semvar update)
  • feat: Introduces a new feature to the codebase (minor semvar update)
  • perf: Performance improvement
  • docs: Documentation only changes
  • tests: Adding missing tests or correcting existing tests
  • chore: Code cleanup tasks, dependency updates, or other changes

Note: Add a ! after your change type to denote a breaking change.

Verification

Automated:

npx mocha --forbid-only "test/unit/lib/run/dyno.unit.test.ts"
npx eslint src/lib/run/dyno.ts test/unit/lib/run/dyno.unit.test.ts

Manual (against a real app with a web process type):

npm run build   # oclif runs from ./dist, so rebuild before exercising the CLI
./bin/run run --exit-code web -a example-http-proxy
  • Before: bash: web: command not found, exit code 127.
  • After: the app's Procfile command runs (node mcp-auth-proxy/index.js), and the CLI passes through the app's real exit code instead of 127.

Additional Context

Root cause is server-side resolution: the runtime looks up a process type by the first whitespace-delimited token of the command (app.process_types.find_by(name: normalized_command.split(/\s+/).first)), then substitutes the real command while keeping trailing args. web; matched nothing, so web ran verbatim. The one-character fix (space before ;) keeps the token web and leaves ; echo … as trailing shell, preserving exit-code propagation. The change flows through run, run:inside, and rake, which all route through Dyno.

Reproduction:

  • heroku run web → works.
  • heroku run --exit-code web → expected: process type runs and its exit code is returned; actual (before fix): command not found, exit 127.

Related Issue

Closes #1227

@michaelmalave michaelmalave requested a review from a team as a code owner July 7, 2026 16:22
@michaelmalave michaelmalave changed the title fix: keep process type resolvable with heroku run --exit-code (W-15930593) fix: keep process type resolvable with heroku run --exit-code Jul 7, 2026

@sbosio sbosio left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM!

@michaelmalave michaelmalave merged commit 6383b03 into main Jul 7, 2026
19 checks passed
@michaelmalave michaelmalave deleted the mm/fix/run-exit-code-procfile-fix branch July 7, 2026 18:15
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

heroku run procfileentry breaks with --exit-code

2 participants