Home / Function/ run() — svelte Function Reference

run() — svelte Function Reference

Architecture documentation for the run() function in renderer.js from the svelte codebase.

Entity Profile

Dependency Diagram

graph TD
  d7a0f423_f1a7_8db9_80a9_89a423021e62["run()"]
  ce85d155_9f13_f67c_9824_407161a6c2c7["Renderer"]
  d7a0f423_f1a7_8db9_80a9_89a423021e62 -->|defined in| ce85d155_9f13_f67c_9824_407161a6c2c7
  3b9fcc16_eee3_208a_bc65_45c294d8565a["run()"]
  d7a0f423_f1a7_8db9_80a9_89a423021e62 -->|calls| 3b9fcc16_eee3_208a_bc65_45c294d8565a
  fd36db6e_7997_3606_5582_56b6e78ced09["set_ssr_context()"]
  d7a0f423_f1a7_8db9_80a9_89a423021e62 -->|calls| fd36db6e_7997_3606_5582_56b6e78ced09
  1e31aba2_e11a_1dfa_89a2_5b7a2d9af208["fn()"]
  d7a0f423_f1a7_8db9_80a9_89a423021e62 -->|calls| 1e31aba2_e11a_1dfa_89a2_5b7a2d9af208
  6f1eae94_35bd_e5bc_d962_31f3ce608951["push()"]
  d7a0f423_f1a7_8db9_80a9_89a423021e62 -->|calls| 6f1eae94_35bd_e5bc_d962_31f3ce608951
  style d7a0f423_f1a7_8db9_80a9_89a423021e62 fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

packages/svelte/src/internal/server/renderer.js lines 145–172

	run(thunks) {
		const context = ssr_context;

		let promise = Promise.resolve(thunks[0]());
		const promises = [promise];

		for (const fn of thunks.slice(1)) {
			promise = promise.then(() => {
				const previous_context = ssr_context;
				set_ssr_context(context);

				try {
					return fn();
				} finally {
					set_ssr_context(previous_context);
				}
			});

			promises.push(promise);
		}

		// prevent unhandled rejections, and attach the promise to the renderer instance
		// so that rejections correctly cause rendering to fail
		promise.catch(noop);
		this.promise = promise;

		return promises;
	}

Domain

Subdomains

Frequently Asked Questions

What does run() do?
run() is a function in the svelte codebase, defined in packages/svelte/src/internal/server/renderer.js.
Where is run() defined?
run() is defined in packages/svelte/src/internal/server/renderer.js at line 145.
What does run() call?
run() calls 4 function(s): fn, push, run, set_ssr_context.

Analyze Your Own Codebase

Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.

Try Supermodel Free