Skip to content

fix(server-core): log a server entry deactivate error instead of stopping the next project - #391

Open
Exeloo wants to merge 16 commits into
mainfrom
fix/server-plugins-deactivate
Open

Exeloo wants to merge 16 commits into
mainfrom
fix/server-plugins-deactivate

Conversation

@Exeloo

@Exeloo Exeloo commented Nov 29, 2026 •

Copy link
Copy Markdown
Member

What does this PR do?

Closes #255
Refs #263

A server plugin whose deactivate throws no longer stops the switch to the next project: ServerPluginHost._stop logs Server entry failed to deactivate and goes on, so syncProject, _replace and the restore of a shadowed copy keep working. The new unit specs for ServerPluginHost and ProjectRegistry (#263) found more ordering bugs in the same host, fixed here too:

  • a subscription dispose error is logged too, instead of stopping the next project;
  • deactivate(name, dir) keeps the shadowed copy when it stopped nothing (install or uninstall in another folder);
  • a different copy asked for while another copy of that plugin activates now runs after it, instead of being dropped;
  • a project copy asked for before its project closed never starts, and of two overlapping syncProject calls the newest one wins;
  • a project sync waits only for project activations and the names it wants, including a project copy queued behind another copy or run again after a failed copy;
  • one source rank decides which copy runs and which is shadowed: bundled < installed < project < dev. Updating the installed copy keeps a running project copy, and a dev copy keeps running over a project copy;
  • a failed project copy runs the shadowed copy again; dispose restores no shadowed copy.

ProjectRegistry gets unit tests only (sharing and closing, refused folders, sweep, trust, the gateway path with fakes, an unreadable recent-projects.json). #263 stays open: the watcher, unreadable-listing and registry _apply paths are tested on their own branches.

How do you test this PR?

  • A server plugin whose deactivate throws stops the server plugins of the next project #255: the three new tests ("starts the next project when a deactivate throws, and logs the error", "runs the shadowed copy again when the project copy fails to deactivate", "replaces a copy whose deactivate throws") before: 3/3 failed with promise rejected "Error: boom"; after: 3/3 pass.
  • Each later fix has its own test that failed before it and passes after, for example "does not start a project copy when a newer sync closed its project" (expected ['@acme/a'] to deeply equal [] before), "keeps a dev copy over the project copy asked for meanwhile", "runs no shadowed copy again on dispose", "stops the project copy run again after a dev copy failed, when its project closed" (expected 'project on' to be 'project off' before). The reviewers' scripted orderings were rerun after each round and give the expected result.
  • Commands run from the worktree on dcd8b4f: server-core vitest (26 files, 164 passed, 0 skipped), test/plugin 5 runs in a row (26/26 each), pnpm typecheck, pnpm lint: all pass. pnpm build ran in round 1. e2e not run (server logic only).
  • Integration: a scratch branch with every editor branch of this sweep merged passed pnpm build, lint, typecheck, pnpm test --force (1014 passed, 1 skipped) and the full e2e suite with the engine (141/141, Chromium only).

Merge danger

  • Two-way door (a revert is enough). @nanoforge-dev/editor-server-core has no runtime dependents outside the editor; merging to main deploys the editor app.
  • Behaviour changes callers could notice: syncProject waits for project activations in flight before it stops copies; an older syncProject returns early once a newer one starts; an installed or bundled copy no longer replaces a running project copy; a dev copy beats a project copy; dispose no longer restores shadowed copies.
  • Known limits, marked with shortcut: comments: one shadowed copy per name; updating an installed copy that shadows a bundled one starts the bundled copy for a moment; dispose does not stop an activation still pending; a hung project activate holds every later sync.
  • packages/server-core/test/project/project-registry.spec.ts is also created by fix/server-core-fs-safety (fix(server-core): keep project file operations inside the project #384) and fix/load-missing-folder (fix(editor): say a missing folder of a link is missing before the trust prompt #371). Whoever merges second or third folds the tests together: one top-level setup, the later suites inside their own describe.
  • Many small commits rewrite the same lines of server-plugins.ts: squash at merge.

Follow-up issues

Quality gate

Lane Result HEAD covered
Docs N/A: internal host logic, no documented behaviour changed (docs-writer) round 1
Correctness Pass after 5 rounds (final narrow check) dcd8b4f
Performance Pass: not a hot path round 1
Accessibility N/A: no UI -
Security Pass after 5 rounds (final narrow check) dcd8b4f
Style Pass (pnpm lint; 2 taste notes) round 1; lint on dcd8b4f

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

packages:server-core Related to Server core package

Projects

None yet

Development

Successfully merging this pull request may close these issues.

A server plugin whose deactivate throws stops the server plugins of the next project

1 participant