Home / Function/ restartContainer() — astro Function Reference

restartContainer() — astro Function Reference

Architecture documentation for the restartContainer() function in restart.ts from the astro codebase.

Entity Profile

Dependency Diagram

graph TD
  50fcf1f5_a122_121d_7d4f_e4580fc86537["restartContainer()"]
  2daba797_7568_42ad_0193_df1cabafb75a["restart.ts"]
  50fcf1f5_a122_121d_7d4f_e4580fc86537 -->|defined in| 2daba797_7568_42ad_0193_df1cabafb75a
  b10fb170_5a7e_6ebe_40a5_6958fe60be52["createContainerWithAutomaticRestart()"]
  b10fb170_5a7e_6ebe_40a5_6958fe60be52 -->|calls| 50fcf1f5_a122_121d_7d4f_e4580fc86537
  11efbd62_1022_3e88_2e76_02de55951878["createRestartedContainer()"]
  50fcf1f5_a122_121d_7d4f_e4580fc86537 -->|calls| 11efbd62_1022_3e88_2e76_02de55951878
  style 50fcf1f5_a122_121d_7d4f_e4580fc86537 fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

packages/astro/src/core/dev/restart.ts lines 75–115

async function restartContainer(container: Container): Promise<Container | Error> {
	const { logger, close, settings: existingSettings } = container;
	container.restartInFlight = true;

	try {
		const { astroConfig } = await resolveConfig(container.inlineConfig, 'dev', container.fs);
		if (astroConfig.security.csp) {
			logger.warn(
				'config',
				"Astro's Content Security Policy (CSP) does not work in development mode. To verify your CSP implementation, build the project and run the preview server.",
			);
		}
		const settings = await createSettings(
			astroConfig,
			container.inlineConfig.logLevel,
			fileURLToPath(existingSettings.config.root),
		);
		await close();
		return await createRestartedContainer(container, settings);
	} catch (_err) {
		const error = createSafeError(_err);
		// Print all error messages except ZodErrors from AstroConfig as the pre-logged error is sufficient
		if (!isAstroConfigZodError(_err)) {
			logger.error(
				'config',
				formatErrorMessage(collectErrorMetadata(error), logger.level() === 'debug') + '\n',
			);
		}
		// Inform connected clients of the config error
		container.viteServer.environments.client.hot.send({
			type: 'error',
			err: {
				message: error.message,
				stack: error.stack || '',
			},
		});
		container.restartInFlight = false;
		logger.error(null, 'Continuing with previous valid configuration\n');
		return error;
	}
}

Domain

Subdomains

Frequently Asked Questions

What does restartContainer() do?
restartContainer() is a function in the astro codebase, defined in packages/astro/src/core/dev/restart.ts.
Where is restartContainer() defined?
restartContainer() is defined in packages/astro/src/core/dev/restart.ts at line 75.
What does restartContainer() call?
restartContainer() calls 1 function(s): createRestartedContainer.
What calls restartContainer()?
restartContainer() is called by 1 function(s): createContainerWithAutomaticRestart.

Analyze Your Own Codebase

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

Try Supermodel Free