Repository navigation
fix(execd): end a Jupyter run when its kernel shuts down (release-1.3.0) - #33
Conversation
Shutting a kernel down while code runs in it (for example by deleting its context) left the POST /code stream open. The kernel broadcasts shutdown_reply and an idle status, both parented to the shutdown request, then exits without the execution's execute_reply. The Jupyter server keeps the websocket open, so neither KernelDied nor KernelConnectionLost fires, and the idle does not match the request. Handle shutdown_reply by failing the execution with KernelStopped through failExecution, which keeps an outcome the kernel already sent and releases a finalizer that is waiting for the reply.
Codex Review Summary: ✅ CompletedThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: cf2efcb6e9
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| Base: upstream tag `release-1.3.0` (commit `8408f65f`), the stable 1.3.0 | ||
| umbrella release. |
There was a problem hiding this comment.
Keep Markdown paragraphs on single lines
The new FORK.md hard-wraps prose paragraphs and list items throughout the file, beginning with this paragraph. Repository conventions require every Markdown paragraph and list item to remain on one line so editors handle soft wrapping; please join the wrapped prose lines without changing their content.
AGENTS.md reference: AGENTS.md:L114-L116
Useful? React with 👍 / 👎.
Summary
Re-cuts the execd kernel-stop patch onto the stable
release-1.3.0tag (8408f65f). Base branchfeat/execd-kernel-stop-1.3.0is the bare tag, so this PR shows only the patch.Upstream now covers most of what the
release-1.1.1branch carried (#31, #32): since 1.2.0 a run ends when its kernel dies (restarting/dead,KernelDied) or its websocket drops (KernelConnectionLost), and since 1.3.0 a replied run is finalized when output goes quiet. Those commits are not carried forward, and the run-message matching and wake-up patch from #32 is dropped this cycle (its cause is fixed in ipykernel 7.4.0).shutdown_replyand anidlestatus, both parented to the shutdown request, and exits without the cell'sexecute_reply. Jupyter Server keeps the websocket open, so neitherKernelDiednorKernelConnectionLostfires,release-1.3.0has no handler forshutdown_reply, and theidledoes not match the run's request. The/codestream stays open, sending only pings.Change (
components/execd/pkg/jupyter/execute): aMsgShutdownReplyconstant and a handler that fails the run in flight through the existingfailExecutionwithenameKernelStopped. LikeKernelDied, it keeps an outcome the kernel already sent (the cell's own error or its reply) and releases a finalizer already waiting for the reply. One sentence indocs/api/index.md;FORK.mddescribes the branch.Not covered (in
FORK.md): native code that holds the GIL blocks the kernel's shutdown reply, so its run is not ended by this patch.Commits:
a92280e3fix(execd): end a Jupyter run when its kernel shuts downcf2efcb6docs(fork): describe the execd kernel-shutdown patch branchTesting
go test -race -count=1 -run 'KernelShutsDown|KernelShutdown' ./pkg/jupyter/execute/with only theMsgShutdownReplyconstant (no handler): both new tests fail, every case withresultChan was not closed within 3s; got 0 results.go test -race -count=3 ./pkg/jupyter/...passes.TestExecuteCodeStreamFailsWhenKernelShutsDownreplays the shutdown sequence over a websocket kept open;TestExecuteCodeStreamKernelShutdownKeepsReceivedOutcomecovers no reply, a matchingidlewithout a reply (finalizer polling), an IOPub error, and an error reply.Breaking Changes
errorwithenameKernelStopped) and the stream closes.Merge with a merge commit (not squash or rebase): an image is built from the head commit, which must stay reachable from the base branch.
🤖 Generated with Claude Code
Open in [code]smith · Need help on this PR? Tag
@codesmith-botwith what you need.