run() — svelte Function Reference
Architecture documentation for the run() function in async.js from the svelte codebase.
Entity Profile
Dependency Diagram
graph TD 9a4a3f08_7a6a_f871_c243_a35a6690f3f7["run()"] 1ad3e508_c069_abae_2e4a_bd17c8892e18["async.js"] 9a4a3f08_7a6a_f871_c243_a35a6690f3f7 -->|defined in| 1ad3e508_c069_abae_2e4a_bd17c8892e18 b9aaaccb_7510_28de_bb53_f808b2cb1d5e["flatten()"] b9aaaccb_7510_28de_bb53_f808b2cb1d5e -->|calls| 9a4a3f08_7a6a_f871_c243_a35a6690f3f7 61349edc_4397_493f_bcdc_aa9a9b92ec3c["capture()"] 9a4a3f08_7a6a_f871_c243_a35a6690f3f7 -->|calls| 61349edc_4397_493f_bcdc_aa9a9b92ec3c 2c67b85b_d904_f73c_3422_6086d51dc1d1["get_boundary()"] 9a4a3f08_7a6a_f871_c243_a35a6690f3f7 -->|calls| 2c67b85b_d904_f73c_3422_6086d51dc1d1 2ba0836c_3ec9_0e68_f2ba_cf1bb3adc645["is_rendered()"] 9a4a3f08_7a6a_f871_c243_a35a6690f3f7 -->|calls| 2ba0836c_3ec9_0e68_f2ba_cf1bb3adc645 95fd9978_b635_37dc_dfee_13c687d48cd6["update_pending_count()"] 9a4a3f08_7a6a_f871_c243_a35a6690f3f7 -->|calls| 95fd9978_b635_37dc_dfee_13c687d48cd6 ab9c13ec_1c6d_0b81_72f5_188dfda4191b["increment()"] 9a4a3f08_7a6a_f871_c243_a35a6690f3f7 -->|calls| ab9c13ec_1c6d_0b81_72f5_188dfda4191b fb22ea33_bcce_fa0a_2303_a0b855ff25ad["aborted()"] 9a4a3f08_7a6a_f871_c243_a35a6690f3f7 -->|calls| fb22ea33_bcce_fa0a_2303_a0b855ff25ad 623c7d5f_8856_1cec_42aa_d58e310da5d1["invoke_error_boundary()"] 9a4a3f08_7a6a_f871_c243_a35a6690f3f7 -->|calls| 623c7d5f_8856_1cec_42aa_d58e310da5d1 db550759_ee3b_160c_8afa_d1aa9fae478c["fn()"] 9a4a3f08_7a6a_f871_c243_a35a6690f3f7 -->|calls| db550759_ee3b_160c_8afa_d1aa9fae478c ea5280ff_3b87_42ee_3823_3570b76a5779["push()"] 9a4a3f08_7a6a_f871_c243_a35a6690f3f7 -->|calls| ea5280ff_3b87_42ee_3823_3570b76a5779 df71411d_ad64_65b8_da29_e77890377349["unset_context()"] 9a4a3f08_7a6a_f871_c243_a35a6690f3f7 -->|calls| df71411d_ad64_65b8_da29_e77890377349 a0b8f840_863f_a966_d259_b866f80703d1["deactivate()"] 9a4a3f08_7a6a_f871_c243_a35a6690f3f7 -->|calls| a0b8f840_863f_a966_d259_b866f80703d1 a985ae40_8ef8_7ef2_adad_116fbf97e70c["effect()"] 9a4a3f08_7a6a_f871_c243_a35a6690f3f7 -->|calls| a985ae40_8ef8_7ef2_adad_116fbf97e70c style 9a4a3f08_7a6a_f871_c243_a35a6690f3f7 fill:#6366f1,stroke:#818cf8,color:#fff
Relationship Graph
Source Code
packages/svelte/src/internal/client/reactivity/async.js lines 224–295
export function run(thunks) {
const restore = capture();
var boundary = get_boundary();
var batch = /** @type {Batch} */ (current_batch);
var blocking = boundary.is_rendered();
boundary.update_pending_count(1);
batch.increment(blocking);
var active = /** @type {Effect} */ (active_effect);
/** @type {null | { error: any }} */
var errored = null;
/** @param {any} error */
const handle_error = (error) => {
errored = { error }; // wrap in object in case a promise rejects with a falsy value
if (!aborted(active)) {
invoke_error_boundary(error, active);
}
};
var promise = Promise.resolve(thunks[0]()).catch(handle_error);
/** @type {Blocker} */
var blocker = { promise, settled: false };
var blockers = [blocker];
promise.finally(() => {
blocker.settled = true;
});
for (const fn of thunks.slice(1)) {
promise = promise
.then(() => {
if (errored) {
throw errored.error;
}
if (aborted(active)) {
throw STALE_REACTION;
}
restore();
return fn();
})
.catch(handle_error);
const blocker = { promise, settled: false };
blockers.push(blocker);
promise.finally(() => {
blocker.settled = true;
unset_context();
current_batch?.deactivate();
});
}
promise
// wait one more tick, so that template effects are
// guaranteed to run before `$effect(...)`
.then(() => Promise.resolve())
.finally(() => {
boundary.update_pending_count(-1);
batch.decrement(blocking);
});
return blockers;
}
Domain
Subdomains
Calls
Called By
Source
Frequently Asked Questions
What does run() do?
run() is a function in the svelte codebase, defined in packages/svelte/src/internal/client/reactivity/async.js.
Where is run() defined?
run() is defined in packages/svelte/src/internal/client/reactivity/async.js at line 224.
What does run() call?
run() calls 13 function(s): aborted, capture, deactivate, decrement, effect, fn, get_boundary, increment, and 5 more.
What calls run()?
run() is called by 1 function(s): flatten.
Analyze Your Own Codebase
Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.
Try Supermodel Free