Skip to content

fix(jupyter): handle shutdown and interrupt requests per protocol#32359

Merged
bartlomieju merged 5 commits intodenoland:mainfrom
bartlomieju:jupyter_kernel_conformance
Mar 2, 2026
Merged

fix(jupyter): handle shutdown and interrupt requests per protocol#32359
bartlomieju merged 5 commits intodenoland:mainfrom
bartlomieju:jupyter_kernel_conformance

Conversation

@bartlomieju
Copy link
Member

@bartlomieju bartlomieju commented Feb 27, 2026

Summary

  • Send shutdown_reply on the control channel before exiting, with the restart field echoed back from the request
  • Handle interrupt_request by calling v8::IsolateHandle::terminate_execution() to actually interrupt running JS code (e.g. infinite loops), then send interrupt_reply
  • Clear the V8 termination flag (cancel_terminate_execution()) before each evaluation so the kernel remains usable after an interrupt
  • Implement is_complete_request with bracket/brace/paren balancing instead of always replying "complete" — also handles unterminated strings, template literals, and comments
  • Add integration tests for shutdown reply, interrupt reply, and interrupt of running code with subsequent execution
  • Add 16 unit tests for is_complete logic

Verified against the kernel-testbed conformance suite: 26/26 (100%), up from 92%.

Closes #32357

Test plan

  • jupyter_shutdown_reply — sends shutdown, verifies reply content and clean process exit
  • jupyter_shutdown_restart_reply — verifies restart: true is echoed back
  • jupyter_interrupt_reply — verifies reply on control channel
  • jupyter_interrupt_running_code — starts while (true) {}, interrupts it, verifies the kernel can still execute code afterward
  • 16 unit tests for check_is_complete covering balanced/unbalanced brackets, strings, comments, template literals, and edge cases
  • All pre-existing jupyter tests continue to pass
  • Full kernel-testbed conformance suite passes 26/26

🤖 Generated with Claude Code

bartlomieju and others added 3 commits February 27, 2026 20:17
The Jupyter kernel was not sending replies for `shutdown_request` and
`interrupt_request` messages on the control channel, causing conformance
test timeouts. Now the kernel sends proper `shutdown_reply` (with the
`restart` field echoed back) before exiting, and `interrupt_reply` after
terminating V8 execution via `IsolateHandle::terminate_execution()`.
Before each subsequent evaluation, `cancel_terminate_execution()` clears
the termination flag so the kernel remains usable after an interrupt.

Closes denoland#32357

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Instead of always replying "complete", check whether the code has
balanced brackets, braces, parens, and terminated strings/comments.
Returns "incomplete" for unterminated constructs and "invalid" for
mismatched delimiters.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Copy link
Member

@nathanwhit nathanwhit left a comment

Choose a reason for hiding this comment

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

LGTM

@bartlomieju bartlomieju merged commit d428817 into denoland:main Mar 2, 2026
112 checks passed
@bartlomieju bartlomieju deleted the jupyter_kernel_conformance branch March 2, 2026 10:05
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.

Deno Jupyter Kernel Conformance

3 participants