fix(spell-check): recreate worker after dispose to survive SuperDoc reinit#2933
Open
mattConnHarbour wants to merge 2 commits intomainfrom
Open
fix(spell-check): recreate worker after dispose to survive SuperDoc reinit#2933mattConnHarbour wants to merge 2 commits intomainfrom
mattConnHarbour wants to merge 2 commits intomainfrom
Conversation
f7db4d3 to
535be62
Compare
caio-pizzol
approved these changes
May 6, 2026
Contributor
caio-pizzol
left a comment
There was a problem hiding this comment.
hey @mattConnHarbour! good call - the App.tsx reinit pattern needed this :)
two small things inline, feel free to skip.
| cleanup(); | ||
| const cancel: TypoWorkerCancelMessage = { type: 'cancel', id: requestId }; | ||
| worker.postMessage(cancel); | ||
| ensureWorker().postMessage(cancel); |
Contributor
There was a problem hiding this comment.
ensureWorker().postMessage(cancel) in the abort handler can spin up a fresh worker just to send a cancel for an id it doesn't know. doesn't fire today (the dispose loop removes the abort listener via entry.cleanup()), but the abort path shouldn't have worker-creating side effects.
Suggested change
| ensureWorker().postMessage(cancel); | |
| worker?.postMessage(cancel); |
| @@ -18,7 +19,18 @@ function createAbortError(): DOMException | Error { | |||
|
|
|||
| export async function createTypoJsProvider() { | |||
| // Run Typo.js work inside a dedicated worker to avoid UI stalls. | |||
Contributor
There was a problem hiding this comment.
worth saying why in the comment - the next reader has to open App.tsx to see the lifecycle.
Suggested change
| // Run Typo.js work inside a dedicated worker to avoid UI stalls. | |
| // Worker is lazily created/recreated to survive dispose() calls | |
| // (App.tsx reuses the same provider across SuperDoc destroy/recreate). |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
After document upload and SD reinit, worker was not being recreated. This PR fixes ensures a worker is always available.