Skip to content

fix(core): record editor opens after a cancelled initial build - #244

Merged
martin-fleck-at merged 1 commit into
mainfrom
fix/242-cancelled-build-gates-opens
Sep 30, 2026
Merged

martin-fleck-at merged 1 commit into
mainfrom
fix/242-cancelled-build-gates-opens

Conversation

@martin-fleck-at

Copy link
Copy Markdown
Contributor

When the initial workspace build was cancelled, the server stopped recording the editor's opens for the rest of its life, without a log line. The text store waited on workspaceInitialized before it recorded an open, and a cancelled build, which any write during startup causes, rejects that promise for good. From then on every open was dropped, the editor's changes were ignored as stale, and nothing the server wrote was pushed to the editor, so a save from it could overwrite other clients' edits. Closing the editor's documents when its worker port closed hung on the same promise. This change has the store's two gates wait for the initial build to finish, whether it completed, was cancelled or failed, as ModelService.ready already did.

A failed initial build is now logged once, by the workspace manager, where it happens: at error for a real failure, at debug for a cancellation or a connection that went away at teardown. Every framework waiter discards the rejection, and the workspace manager's log does not depend on ModelService having been constructed, which in a host without a data server may never happen.

What changes for adopters

  • HydraniumTextDocuments.initialBuildFinished() is a new protected method. The LSP didOpen handler and closeLanguageClientDocuments() await it.
  • HydraniumWorkspaceManager.initializeWorkspace logs a failed setup before it rejects workspaceInitialized. An override that rejects the deferred itself, without calling super, logs its own failure.
  • ModelService.ready no longer logs the rejection at debug; it still never rejects.
  • workspaceInitialized is unchanged: it still rejects when the initial build does not complete, so a caller relying on that keeps working.

How I know it works

Against main, both new tests fail for the reason they name:

  • The store test (an editor open over a worker port after a cancelled initial build) times out waiting for the open to be recorded.
  • The workspace manager test finds no error line for a failed build (expected one, received none).

Fixes #242.

The text store waited on workspaceInitialized before it recorded an
editor's open or closed the editor's documents. A cancelled initial
build, which any write during startup causes, rejects that promise for
good, so every later open was dropped without a log line and the
editor's documents were never synced.

- The store's open and close gates wait for the initial build to
  finish, whether it completed, was cancelled or failed
- The workspace manager logs a failed initial build as an error, and a
  cancelled one or a gone connection at debug; ModelService.ready no
  longer logs it
- workspaceInitialized still rejects when the build does not complete

New public names
- The protected HydraniumTextDocuments.initialBuildFinished

Fixes #242
@martin-fleck-at
martin-fleck-at merged commit 0a17cbf into main Sep 30, 2026
12 of 13 checks passed
@martin-fleck-at
martin-fleck-at deleted the fix/242-cancelled-build-gates-opens branch September 30, 2026 15:33
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.

A cancelled initial build makes the server ignore every editor open for the rest of its life

1 participant