Skip to content

fix: ignore completions for disposed models - #5613

Open
whoalin1 wants to merge 1 commit into
microsoft:mainfrom
whoalin1:devin/1796138000-completion-disposal
Open

whoalin1 wants to merge 1 commit into
microsoft:mainfrom
whoalin1:devin/1796138000-completion-disposal

Conversation

@whoalin1

Copy link
Copy Markdown

Fixes #5612

CompletionAdapter.provideCompletionItems awaited the language worker and then read from the model without checking whether the model had been disposed or the completion request had been cancelled. If an editor was unmounted while a JSON/CSS/HTML worker request was in flight, model.getWordUntilPosition(position) could throw TextModelPart is disposed! as an unhandled error.

Return no completion result when the model is disposed or cancellation was requested before mapping the worker response. This matches the disposal guards already used by the TypeScript completion adapter.

Validation:

  • Reproduced the race with a focused jsdom-based probe: before the fix it threw TextModelPart is disposed!; after the fix the disposed-model request resolved to undefined.
  • Verified the same probe still maps a normal active-model worker response to one suggestion.
  • npm run test:lsp-client passed: 9 tests.
  • npm run build-monaco-editor passed.
  • git diff --check passed.
  • npx tsc -p ./src --noEmit was attempted but still fails on the pre-existing unrelated src/languages/definitions/wgsl/wgsl.ts ES6-regexp-target error.

Not run: browser smoke tests.

Co-Authored-By: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>
@whoalin1

whoalin1 commented Dec 1, 2026

Copy link
Copy Markdown
Author

Independent targeted validation on 027320a: I exercised the PR’s exact CompletionAdapter source in a lightweight harness with editor primitives mocked. A disposed model returns undefined without calling getWordUntilPosition, a cancelled request returns undefined, and an active model still returns the expected completion item (disposed=undefined, cancelled=undefined, active=1). Full editor build not run; this validates the disposal/cancellation regression path directly.

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.

[Bug] JSON/CSS/HTML completion throws "TextModelPart is disposed!" when the model is disposed while the worker answers

1 participant