[codex] Fix restart-provider stop crash reporting#60
Draft
brsbl wants to merge 1 commit into
Draft
Conversation
Author
|
cc @ymichael |
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.
Bug description
When the idle provider watchdog requested
thread.stopfor a wedged provider turn, the host daemon could report the stop as a provider crash:thread.stopcommandProvider "codex" exited unexpectedlyrestart-providerstop is supposed to tear the provider downThe same log bundle also contained app-data resync Zod errors and daemon reconnects. Those are separate findings and intentionally left out of this crash fix.
Root cause
For
restart-providerstop plans,runtime.stopThreadsent the provider interrupt request and awaited the JSON-RPC response before treating provider shutdown as expected.If the provider process exited while the interrupt was still in flight, the pending request rejected from the process-exit path as
Provider "<id>" exited unexpectedly. That rejection propagated out ofstopThread, so the server marked the stop command as failed and host-daemon emitted an unexpected provider-exit event.The race was legitimate for
restart-provider: the provider exiting during/after interrupt is the intended stop outcome, not a crash.Evidence
restart-providerstop request is in flight, causingstopThreadto reject before this fix.signalCodewithexitCode === null)restart-providerstops on the same provider processProposed fix
RuntimeProviderProcessManager.markProviderShutdownExpected()mints a token and records it on the live process.clearProviderShutdownExpected()removes only the caller's token, so overlapping stop operations cannot clear each other's expected shutdown marks.hasChildProcessExited()to treat either normal exits or signal terminations as provider exits.runtime.stopThreadsorestart-providerstops:Validation
Worker validation:
pnpm exec turbo run typecheck --filter=@bb/agent-runtime✅pnpm --filter @bb/agent-runtime exec vitest run --testTimeout=30000✅548/548passing across 28 filesReview validation:
git diff --check✅Out of scope / follow-up
The app-data resync ZodError in the original logs appears to be a separate schema drift in the app data resync hint path. It is not part of this provider stop crash and should be handled in a focused follow-up.