Skip to content

fix(jupyter-notebook): close servers that finish launching during shutdown - #148

Open
JunkaiWang-TheoPhy wants to merge 1 commit into
zai-org:mainfrom
JunkaiWang-TheoPhy:codex/close-jupyter-launch-during-shutdown
Open

JunkaiWang-TheoPhy wants to merge 1 commit into
zai-org:mainfrom
JunkaiWang-TheoPhy:codex/close-jupyter-launch-during-shutdown

Conversation

@JunkaiWang-TheoPhy

Copy link
Copy Markdown

Plugin type (required) / 插件类型(必填)

  • UI Plugin
  • Standard plugin
  • Not applicable

Affected plugin: jupyter-notebook.

What

Closing the plugin while start_server is still starting Jupyter can leave a running server outside the registry: closeAll() previously inspected only registered entries, returned, and the pending launch subsequently registered its process. Closing twice could also stop the same owned server twice.

Make registry closure terminal and share its cleanup promise. Shutdown waits for the pending launch; that launch stops its newly obtained process if shutdown has already begun, rather than registering a ready server. In-flight and new attachments cannot repopulate a closed registry. Existing attached servers remain external and are not stopped.

Bump the plugin, marketplace, source package and protocol version from 0.2.0 to 0.2.1, with synchronized English/Chinese docs. No new dependencies, permissions or network services are added. Existing Jupyter process execution and notebook access are unchanged.

Verification

On upstream 0cc58d6aa29644f50af1d7ac2fa4c4eb7ada95d9, preserving the new tests and restoring only the old registry:

pnpm exec vitest run src/servers/servers.test.ts
4 failed | 11 passed (15)

pnpm exec vitest run --config vitest.integration.config.ts test/server-shutdown.integration.test.ts
1 failed (1)

The latter uses a real Jupyter process: it remains alive after the old closeAll returns. Cleanup in the test still stops that process.

With the fix:

  • Plugin unit suite: 49 passed.
  • Real Jupyter integration: 15 passed, including the startup/shutdown race.
  • Built stdio MCP smoke: passed.
  • Chrome panel with the official AppBridge and real Jupyter: passed.
  • Plugin build, plugin and repository typecheck: passed.
  • Repository lint: passed with one existing warning outside this plugin; changed-file lint has no warnings.
  • Validator: 52 plugins accepted; git diff check passed.
  • Jupyter installation artifact passed the repository packaging boundary.

Environment: macOS arm64, Node 24.15.0, pnpm 10.33.2, Vitest 4.1.4, Python 3.12.13, Jupyter Server 2.21.1, ipykernel 7.4.0.

Outstanding validation

Full repository build stops in the unrelated photocraft snapshot because rustup is unavailable; full distribution packaging then rejects that incomplete plugin. Root tests also require unbuilt KiCad artifacts. These failures have not been bypassed or labeled as passing.

Current ZCode Desktop installation verification remains incomplete. The official 3.17.1 macOS arm64 release was integrity-checked and launched with independent runtime/data directories and a restrictive OS sandbox that denies access to production user data. It exited during startup because its telemetry store still targets the denied production Application Support path and Electron sandbox initialization fails in that isolation. Production data access and internal sandbox restrictions were not relaxed. The official AppBridge browser check above is a distinct, passing test surface.

AI disclosure: investigation, implementation and local verification used OpenAI Codex assistance.

Self-check

  • Existing plugin ownership retained; no root scripts/tests/workflow changes
  • UI Plugin and affected name declared
  • Manifest, marketplace and source versions synchronized
  • Equivalent English and Chinese docs updated
  • No credentials, private data or machine-specific paths in the patch
  • Dependencies, networking and side effects documented
  • Full repository build/distribution packaging
  • Current ZCode Desktop installation verification

Closing only registered entries misses an owned process whose launch is still in flight. Close admission, drain the pending launch, and share one cleanup promise while keeping attached servers outside plugin ownership.

Confidence: high
Scope-risk: narrow
Tested: Old registry fails four unit regressions and a real Jupyter process regression; fixed49 unit and15 real integration tests; MCP smoke, AppBridge E2E, types and lint
Not-tested: Current native Desktop install remains incomplete; unrelated full build requires missing rustup
@panda920

panda920 commented Nov 1, 2026

Copy link
Copy Markdown
Collaborator

✅ Internal validation passed. A ZCode maintainer will review the change next; after acceptance, release checks run separately and this PR is closed automatically.

This branch has not been deployed

No deployments
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.

2 participants