fix(codex): don't clobber codex.js — rm npm symlink before writing the Bedrock wrapper#200
Merged
Conversation
…g the wrapper The Bedrock wrapper was installed with 'base64 -d > /usr/local/bin/codex', but 'npm install -g' leaves that path as a SYMLINK to the real launcher (.../node_modules/@openai/codex/bin/codex.js). The redirect followed the symlink and overwrote codex.js with the wrapper itself, so the wrapper's exec "$REAL" (REAL=codex.js) re-exec'd the wrapper -> infinite exec recursion -> codex hangs on every launch (asks-for-login / spins forever). Fix: 'rm -f /usr/local/bin/codex' before the redirect so a real file is created at the bin path and codex.js stays the genuine launcher. Verified on a live pod: with codex.js restored + wrapper as a real file, 'codex exec' as dev returns 'hi' via bedrock/openai.gpt-5.5 (effort high). The token mint, the responses endpoint, and SSE streaming were all confirmed healthy — the hang was purely the recursion.
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.
Symptom
codexhangs on launch (appears to ask for ChatGPT login / spins forever) on pods built from the #198 image.Root cause
The Bedrock wrapper is installed with:
But
npm install -g --prefix /usr/local @openai/codexleaves/usr/local/bin/codexas a symlink →../lib/node_modules/@openai/codex/bin/codex.js. The redirect follows the symlink and overwritescodex.jsitself with the wrapper. The wrapper doesexec "$REAL"whereREAL=.../codex.js— which is now the wrapper — so it execs itself forever (infiniteexecverecursion) → hang.Proof:
node codex.js --versionerrors withSyntaxError: Invalid or unexpected tokenon the line# Codex wired to GPT-5.5...— i.e. node is parsing the bash wrapper as JS, because codex.js is the wrapper.Fix
rm -f /usr/local/bin/codexbefore the redirect, so a real file is written at the bin path andcodex.jsstays the genuine launcher.Verification (live pod)
aws_bedrock_token_generator): OK (2208-charbedrock-api-key-…)POST /openai/v1/responses(non-stream): 200, "Hi!", 0.49scodex execasdevreturns "hi" viaprovider=bedrock model=openai.gpt-5.5, reasoning effort high.So the API/auth/network were always healthy — the hang was purely the recursion.
Deploy
Needs the image rebuild (
tofu applyprod). Existing pods on the bad image can be repaired in-place: reinstall codex (npm install -g --prefix /usr/local @openai/codex --force) thenrm -f /usr/local/bin/codex+ reinstate the wrapper as a real file.