File tree Expand file tree Collapse file tree 2 files changed +15
-5
lines changed
packages/svelte/src/internal/client Expand file tree Collapse file tree 2 files changed +15
-5
lines changed Original file line number Diff line number Diff line change 1- /** @import { Effect } from '#client' */
1+ /** @import { Derived, Effect } from '#client' */
22/** @import { Boundary } from './dom/blocks/boundary.js' */
33import { DEV } from 'esm-env' ;
44import { FILENAME } from '../../constants.js' ;
55import { is_firefox } from './dom/operations.js' ;
6- import { BOUNDARY_EFFECT , EFFECT_RAN } from './constants.js' ;
6+ import { ASYNC_ERROR , BOUNDARY_EFFECT , EFFECT_RAN } from './constants.js' ;
77import { define_property , get_descriptor } from '../shared/utils.js' ;
8- import { active_effect } from './runtime.js' ;
8+ import { active_effect , active_reaction } from './runtime.js' ;
99
1010/**
1111 * @param {unknown } error
1212 */
1313export function handle_error ( error ) {
14- var effect = /** @type {Effect } */ ( active_effect ) ;
14+ var effect = active_effect ;
15+
16+ // for unowned deriveds, don't throw until we read the value
17+ if ( effect === null ) {
18+ /** @type {Derived } */ ( active_reaction ) . f |= ASYNC_ERROR ;
19+ return error ;
20+ }
1521
1622 if ( DEV && error instanceof Error ) {
1723 // adjust_error(error, effect);
Original file line number Diff line number Diff line change @@ -369,9 +369,13 @@ export function update_reaction(reaction) {
369369 }
370370 }
371371
372+ if ( ( reaction . f & ASYNC_ERROR ) !== 0 ) {
373+ reaction . f ^= ASYNC_ERROR ;
374+ }
375+
372376 return result ;
373377 } catch ( error ) {
374- handle_error ( error ) ;
378+ return handle_error ( error ) ;
375379 } finally {
376380 reaction . f ^= REACTION_IS_UPDATING ;
377381 new_deps = previous_deps ;
You can’t perform that action at this time.
0 commit comments