Skip to content

fix: preserve context for synchronous async expression errors - #18825

Draft
svelte-triage-bot[bot] wants to merge 1 commit into
mainfrom
triage/svelte-18824-async-boundary-sync-throw
Draft

svelte-triage-bot[bot] wants to merge 1 commit into
mainfrom
triage/svelte-18824-async-boundary-sync-throw

Conversation

@svelte-triage-bot

Copy link
Copy Markdown
Contributor

Summary

Fixes #18824.

  • defer clearing the active reaction context when an async expression throws synchronously
  • allow the original error to reach the enclosing <svelte:boundary> instead of producing a null.f TypeError
  • add a production-client runtime regression test and patch changeset

In production, the awaited expression can compile to a synchronous thunk. Its synchronous-throw path cleared the active context before update_reaction finished, corrupting subsequent error handling. Deferring that cleanup to a microtask keeps the current update valid while preserving the existing asynchronous cleanup behavior.

Tests

  • pnpm vitest run packages/svelte/tests/runtime-runes/test.ts -t async-boundary-sync-throw --reporter=dot
  • pnpm test runtime-runes
  • pnpm test
  • pnpm check
  • pnpm lint
  • pnpm format

@pkg-svelte-dev

Copy link
Copy Markdown

Install the latest version of svelte from 0f87bfa:

pnpm add https://pkg.svelte.dev/svelte/c/0f87bfaafc85a025ed263fe306ed43bac097683f

Open in pkg.svelte.dev: https://pkg.svelte.dev/repos/svelte/pr/18825

Note

This PR is from a fork. A maintainer must approve approve each commit before it can be built and installed.

@changeset-bot

changeset-bot Bot commented Sep 15, 2026

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: 0f87bfa

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 1 package
Name Type
svelte Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

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.

Synchronous throw in an awaited expression becomes null.f

0 participants