Skip to content

fix(spell-check): recreate worker after dispose to survive SuperDoc reinit#2933

Open
mattConnHarbour wants to merge 2 commits intomainfrom
matthew/sd-2505-provider-dispose-fix
Open

fix(spell-check): recreate worker after dispose to survive SuperDoc reinit#2933
mattConnHarbour wants to merge 2 commits intomainfrom
matthew/sd-2505-provider-dispose-fix

Conversation

@mattConnHarbour
Copy link
Copy Markdown
Contributor

After document upload and SD reinit, worker was not being recreated. This PR fixes ensures a worker is always available.

@linear
Copy link
Copy Markdown

linear Bot commented Apr 24, 2026

@mattConnHarbour mattConnHarbour force-pushed the matthew/sd-2505-provider-dispose-fix branch from f7db4d3 to 535be62 Compare April 24, 2026 13:10
Copy link
Copy Markdown
Contributor

@caio-pizzol caio-pizzol left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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);
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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).

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

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants