|
|
@ -615,40 +615,36 @@ function log_effect_stack() {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
function infinite_loop_guard() {
|
|
|
|
function infinite_loop_guard() {
|
|
|
|
if (flush_count > 1000) {
|
|
|
|
try {
|
|
|
|
flush_count = 0;
|
|
|
|
e.effect_update_depth_exceeded();
|
|
|
|
try {
|
|
|
|
} catch (error) {
|
|
|
|
e.effect_update_depth_exceeded();
|
|
|
|
if (DEV) {
|
|
|
|
} catch (error) {
|
|
|
|
// stack is garbage, ignore. Instead add a console.error message.
|
|
|
|
|
|
|
|
define_property(error, 'stack', {
|
|
|
|
|
|
|
|
value: ''
|
|
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
// Try and handle the error so it can be caught at a boundary, that's
|
|
|
|
|
|
|
|
// if there's an effect available from when it was last scheduled
|
|
|
|
|
|
|
|
if (last_scheduled_effect !== null) {
|
|
|
|
if (DEV) {
|
|
|
|
if (DEV) {
|
|
|
|
// stack is garbage, ignore. Instead add a console.error message.
|
|
|
|
try {
|
|
|
|
define_property(error, 'stack', {
|
|
|
|
|
|
|
|
value: ''
|
|
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
// Try and handle the error so it can be caught at a boundary, that's
|
|
|
|
|
|
|
|
// if there's an effect available from when it was last scheduled
|
|
|
|
|
|
|
|
if (last_scheduled_effect !== null) {
|
|
|
|
|
|
|
|
if (DEV) {
|
|
|
|
|
|
|
|
try {
|
|
|
|
|
|
|
|
handle_error(error, last_scheduled_effect, null, null);
|
|
|
|
|
|
|
|
} catch (e) {
|
|
|
|
|
|
|
|
// Only log the effect stack if the error is re-thrown
|
|
|
|
|
|
|
|
log_effect_stack();
|
|
|
|
|
|
|
|
throw e;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
} else {
|
|
|
|
|
|
|
|
handle_error(error, last_scheduled_effect, null, null);
|
|
|
|
handle_error(error, last_scheduled_effect, null, null);
|
|
|
|
}
|
|
|
|
} catch (e) {
|
|
|
|
} else {
|
|
|
|
// Only log the effect stack if the error is re-thrown
|
|
|
|
if (DEV) {
|
|
|
|
|
|
|
|
log_effect_stack();
|
|
|
|
log_effect_stack();
|
|
|
|
|
|
|
|
throw e;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
throw error;
|
|
|
|
} else {
|
|
|
|
|
|
|
|
handle_error(error, last_scheduled_effect, null, null);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
} else {
|
|
|
|
|
|
|
|
if (DEV) {
|
|
|
|
|
|
|
|
log_effect_stack();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
throw error;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
flush_count++;
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
/**
|
|
|
@ -656,33 +652,34 @@ function infinite_loop_guard() {
|
|
|
|
* @returns {void}
|
|
|
|
* @returns {void}
|
|
|
|
*/
|
|
|
|
*/
|
|
|
|
function flush_queued_root_effects(root_effects) {
|
|
|
|
function flush_queued_root_effects(root_effects) {
|
|
|
|
queued_root_effects = [];
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
var length = root_effects.length;
|
|
|
|
|
|
|
|
if (length === 0) {
|
|
|
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
infinite_loop_guard();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
var previously_flushing_effect = is_flushing_effect;
|
|
|
|
var previously_flushing_effect = is_flushing_effect;
|
|
|
|
is_flushing_effect = true;
|
|
|
|
is_flushing_effect = true;
|
|
|
|
|
|
|
|
|
|
|
|
is_flushing = true;
|
|
|
|
is_flushing = true;
|
|
|
|
|
|
|
|
|
|
|
|
try {
|
|
|
|
try {
|
|
|
|
for (var i = 0; i < length; i++) {
|
|
|
|
var length = queued_root_effects.length;
|
|
|
|
var effect = root_effects[i];
|
|
|
|
var flush_count = 0;
|
|
|
|
|
|
|
|
|
|
|
|
if ((effect.f & CLEAN) === 0) {
|
|
|
|
while (queued_root_effects.length > 0) {
|
|
|
|
effect.f ^= CLEAN;
|
|
|
|
if (flush_count++ > 1000) {
|
|
|
|
|
|
|
|
infinite_loop_guard();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
var collected_effects = process_effects(effect);
|
|
|
|
var root_effects = queued_root_effects;
|
|
|
|
flush_queued_effects(collected_effects);
|
|
|
|
var length = root_effects.length;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
queued_root_effects = [];
|
|
|
|
|
|
|
|
|
|
|
|
if (queued_root_effects.length > 0) {
|
|
|
|
for (var i = 0; i < length; i++) {
|
|
|
|
flush_queued_root_effects(queued_root_effects);
|
|
|
|
var effect = root_effects[i];
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if ((effect.f & CLEAN) === 0) {
|
|
|
|
|
|
|
|
effect.f ^= CLEAN;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
var collected_effects = process_effects(effect);
|
|
|
|
|
|
|
|
flush_queued_effects(collected_effects);
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
} finally {
|
|
|
|
} finally {
|
|
|
|
is_flushing_effect = previously_flushing_effect;
|
|
|
|
is_flushing_effect = previously_flushing_effect;
|
|
|
@ -851,8 +848,6 @@ function process_effects(effect) {
|
|
|
|
* @returns {any}
|
|
|
|
* @returns {any}
|
|
|
|
*/
|
|
|
|
*/
|
|
|
|
export function flush_sync(fn) {
|
|
|
|
export function flush_sync(fn) {
|
|
|
|
infinite_loop_guard();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
is_micro_task_queued = false;
|
|
|
|
is_micro_task_queued = false;
|
|
|
|
|
|
|
|
|
|
|
|
flush_queued_root_effects(queued_root_effects);
|
|
|
|
flush_queued_root_effects(queued_root_effects);
|
|
|
|