Skip to content

Commit a0dba34

Browse files
committed
rename ASYNC_ERROR -> ERROR_VALUE, and avoid conflicts with other flags now that it's used with deriveds as well as sources
1 parent 5c0a4a0 commit a0dba34

File tree

4 files changed

+11
-11
lines changed

4 files changed

+11
-11
lines changed

packages/svelte/src/internal/client/constants.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ export const EFFECT_PRESERVED = 1 << 23; // effects with this flag should not be
2727
export const REACTION_IS_UPDATING = 1 << 24;
2828
export const EFFECT_ASYNC = 1 << 25;
2929

30-
export const ASYNC_ERROR = 1;
30+
export const ERROR_VALUE = 1 << 26;
3131

3232
export const STATE_SYMBOL = Symbol('$state');
3333
export const PROXY_PATH_SYMBOL = Symbol('proxy path');

packages/svelte/src/internal/client/error-handling.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
import { DEV } from 'esm-env';
44
import { FILENAME } from '../../constants.js';
55
import { is_firefox } from './dom/operations.js';
6-
import { ASYNC_ERROR, BOUNDARY_EFFECT, EFFECT_RAN } from './constants.js';
6+
import { ERROR_VALUE, BOUNDARY_EFFECT, EFFECT_RAN } from './constants.js';
77
import { define_property, get_descriptor } from '../shared/utils.js';
88
import { active_effect, active_reaction } from './runtime.js';
99

@@ -15,7 +15,7 @@ export function handle_error(error) {
1515

1616
// for unowned deriveds, don't throw until we read the value
1717
if (effect === null) {
18-
/** @type {Derived} */ (active_reaction).f |= ASYNC_ERROR;
18+
/** @type {Derived} */ (active_reaction).f |= ERROR_VALUE;
1919
return error;
2020
}
2121

packages/svelte/src/internal/client/reactivity/deriveds.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
/** @import { Batch } from './batch.js'; */
33
import { DEV } from 'esm-env';
44
import {
5-
ASYNC_ERROR,
5+
ERROR_VALUE,
66
CLEAN,
77
DERIVED,
88
DESTROYED,
@@ -155,14 +155,14 @@ export function async_derived(fn, location) {
155155

156156
if (error) {
157157
if (error !== STALE_REACTION) {
158-
signal.f |= ASYNC_ERROR;
158+
signal.f |= ERROR_VALUE;
159159

160160
// @ts-expect-error the error is the wrong type, but we don't care
161161
internal_set(signal, error);
162162
}
163163
} else {
164-
if ((signal.f & ASYNC_ERROR) !== 0) {
165-
signal.f ^= ASYNC_ERROR;
164+
if ((signal.f & ERROR_VALUE) !== 0) {
165+
signal.f ^= ERROR_VALUE;
166166
}
167167

168168
internal_set(signal, value);

packages/svelte/src/internal/client/runtime.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ import {
2727
EFFECT_ASYNC,
2828
RENDER_EFFECT,
2929
STALE_REACTION,
30-
ASYNC_ERROR
30+
ERROR_VALUE
3131
} from './constants.js';
3232
import { flush_tasks } from './dom/task.js';
3333
import { internal_set, old_values } from './reactivity/sources.js';
@@ -369,8 +369,8 @@ export function update_reaction(reaction) {
369369
}
370370
}
371371

372-
if ((reaction.f & ASYNC_ERROR) !== 0) {
373-
reaction.f ^= ASYNC_ERROR;
372+
if ((reaction.f & ERROR_VALUE) !== 0) {
373+
reaction.f ^= ERROR_VALUE;
374374
}
375375

376376
return result;
@@ -921,7 +921,7 @@ export function get(signal) {
921921
return batch_deriveds.get(derived);
922922
}
923923

924-
if ((signal.f & ASYNC_ERROR) !== 0) {
924+
if ((signal.f & ERROR_VALUE) !== 0) {
925925
throw signal.v;
926926
}
927927

0 commit comments

Comments
 (0)