Skip to content

[web-console] Ignore the Monaco dispose race that is thrown from a timer - #8255

Merged
mihaibudiu merged 1 commit into
mainfrom
fix-monaco-dispose-race-8240
Dec 5, 2026
Merged

mihaibudiu merged 1 commit into
mainfrom
fix-monaco-dispose-race-8240

Conversation

@Karakatiza666

Copy link
Copy Markdown
Contributor

Fixes #8240

Problem

The Web Console unit test job failed in the merge queue although all tests passed. Vitest reported one unhandled error, TextModelPart is disposed!, from the Monaco JSON completion.

vite.config.ts has a filter for this error, but the filter compared the message for equality. Monaco reports the error in two forms:

Form message Matched before
Unhandled rejection TextModelPart is disposed! Yes
Thrown again from a timer by unexpectedErrorHandler in monaco-editor/esm/vs/base/common/errors.js TextModelPart is disposed!\n\n<original stack> No

Change

  • Move the filter to src/lib/functions/vitest/monacoDisposeRace.ts, so that a test can import it.
  • Match the message by its prefix, and look for lspLanguageFeatures in the message or the stack.
  • Add unit tests for both forms, for the Canceled rejection, and for errors that must fail the run.

Not changed

The close timed out after 10000ms line in the failed logs is not the cause. A green merge-queue run (47501715566) prints the same line and exits with code 0.

Testing

  • The test for the timer form fails with the old filter and passes with the new filter.
  • MultiJSONDialog.svelte.spec.ts passes with the new config.
  • The race itself was not reproduced locally.

The unit tests ignore the `TextModelPart is disposed!` error of the Monaco
JSON completion, because a test that disposes the editor soon after typing
can cause it. The filter compared the message for equality. Monaco can also
throw this error again from a timer, with the original stack appended to
the message. The filter did not match that form, so the run failed although
all tests passed. The filter matches the message by its prefix.

Fixes #8240

Signed-off-by: Karakatiza666 <bulakh.96@gmail.com>
@mythical-fred-oss

Copy link
Copy Markdown
Contributor

LGTM.

  • Ran: vitest run --project server src/lib/functions/vitest, 7/7 passed. pre-commit run on the 3 changed files passed.
  • Checked: the PR's account of the cause holds. unexpectedErrorHandler in monaco-editor/esm/vs/base/common/errors.js (the version in our lockfile) rethrows from setTimeout as new Error(e.message + '\n\n' + e.stack), so an exact-match filter can't catch that form. Canceled never takes this path because onUnexpectedError drops cancellation errors first. Keeping the exact match for Canceled is therefore correct.
  • Gates: this changes test infrastructure only, and it comes with unit tests that include negative cases. No user-visible change, no new dependencies, no flakiness introduced.

@mihaibudiu
mihaibudiu added this pull request to the merge queue Dec 5, 2026
Merged via the queue into main with commit ba50626 Dec 5, 2026
3 checks passed
@mihaibudiu
mihaibudiu deleted the fix-monaco-dispose-race-8240 branch December 5, 2026 19:17
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.

Flaky: Web Console Unit Tests — Monaco 'TextModelPart is disposed' unhandled error + close timeout

3 participants