#18824·svelte

Synchronous throw in an awaited expression becomes `null.f`

Author: jkbz64Created Sep 15, 2026Updated Sep 15, 2026

Describe the bug

Synchronous throw errors out as cryptic null.f access instead of the original error in production.

Reproduction

svelte
<script>
  let valid = $state(true);

  function load() {
    if (!valid) throw new Error("original error");
    return Promise.resolve("ready");
  }
</script>

<button onclick={() => (valid = false)}>invalidate</button>

<svelte:boundary>
  <p>{await load()}</p>

  {#snippet pending()}<p>pending</p>{/snippet}
  {#snippet failed(error)}<p>{error.message}</p>{/snippet}
</svelte:boundary>

compile with

javascript
{ generate: "client", dev: false, experimental: { async: true } }

Mount it, wait for ready, and click invalidate.

  • Expected: the boundary renders original error.
  • Actual: Cannot read properties of null (reading 'f') escapes the boundary, which keeps displaying ready.
  • The same problem occurs if the initial promise is still pending.
  • The example deliberately throws a normal Error; no application code accesses a property of null or undefined.

This will NOT manifest in svelte playground because the playground uses dev: true.

Logs

bash

System Info

bash
N/A

Severity

annoyance