rename ASYNC_ERROR -> ERROR_VALUE, and avoid conflicts with other flags now that it's used with deriveds as well as sources

pull/15844/head
Rich Harris 3 months ago
parent 5c0a4a02a5
commit a0dba34770

@ -27,7 +27,7 @@ export const EFFECT_PRESERVED = 1 << 23; // effects with this flag should not be
export const REACTION_IS_UPDATING = 1 << 24;
export const EFFECT_ASYNC = 1 << 25;
export const ASYNC_ERROR = 1;
export const ERROR_VALUE = 1 << 26;
export const STATE_SYMBOL = Symbol('$state');
export const PROXY_PATH_SYMBOL = Symbol('proxy path');

@ -3,7 +3,7 @@
import { DEV } from 'esm-env';
import { FILENAME } from '../../constants.js';
import { is_firefox } from './dom/operations.js';
import { ASYNC_ERROR, BOUNDARY_EFFECT, EFFECT_RAN } from './constants.js';
import { ERROR_VALUE, BOUNDARY_EFFECT, EFFECT_RAN } from './constants.js';
import { define_property, get_descriptor } from '../shared/utils.js';
import { active_effect, active_reaction } from './runtime.js';
@ -15,7 +15,7 @@ export function handle_error(error) {
// for unowned deriveds, don't throw until we read the value
if (effect === null) {
/** @type {Derived} */ (active_reaction).f |= ASYNC_ERROR;
/** @type {Derived} */ (active_reaction).f |= ERROR_VALUE;
return error;
}

@ -2,7 +2,7 @@
/** @import { Batch } from './batch.js'; */
import { DEV } from 'esm-env';
import {
ASYNC_ERROR,
ERROR_VALUE,
CLEAN,
DERIVED,
DESTROYED,
@ -155,14 +155,14 @@ export function async_derived(fn, location) {
if (error) {
if (error !== STALE_REACTION) {
signal.f |= ASYNC_ERROR;
signal.f |= ERROR_VALUE;
// @ts-expect-error the error is the wrong type, but we don't care
internal_set(signal, error);
}
} else {
if ((signal.f & ASYNC_ERROR) !== 0) {
signal.f ^= ASYNC_ERROR;
if ((signal.f & ERROR_VALUE) !== 0) {
signal.f ^= ERROR_VALUE;
}
internal_set(signal, value);

@ -27,7 +27,7 @@ import {
EFFECT_ASYNC,
RENDER_EFFECT,
STALE_REACTION,
ASYNC_ERROR
ERROR_VALUE
} from './constants.js';
import { flush_tasks } from './dom/task.js';
import { internal_set, old_values } from './reactivity/sources.js';
@ -369,8 +369,8 @@ export function update_reaction(reaction) {
}
}
if ((reaction.f & ASYNC_ERROR) !== 0) {
reaction.f ^= ASYNC_ERROR;
if ((reaction.f & ERROR_VALUE) !== 0) {
reaction.f ^= ERROR_VALUE;
}
return result;
@ -921,7 +921,7 @@ export function get(signal) {
return batch_deriveds.get(derived);
}
if ((signal.f & ASYNC_ERROR) !== 0) {
if ((signal.f & ERROR_VALUE) !== 0) {
throw signal.v;
}

Loading…
Cancel
Save