Home / Function/ PERSIST_SYMBOL() — astro Function Reference

PERSIST_SYMBOL() — astro Function Reference

Architecture documentation for the PERSIST_SYMBOL() function in runtime.ts from the astro codebase.

Entity Profile

Dependency Diagram

graph TD
  c5fcfb22_1acd_7d18_d142_3d656d477a03["PERSIST_SYMBOL()"]
  91969197_292d_3b15_21c6_0e876968e961["AstroSession"]
  c5fcfb22_1acd_7d18_d142_3d656d477a03 -->|defined in| 91969197_292d_3b15_21c6_0e876968e961
  3459dc7b_97b3_22f8_91b9_dc3a8658682c["stringify()"]
  c5fcfb22_1acd_7d18_d142_3d656d477a03 -->|calls| 3459dc7b_97b3_22f8_91b9_dc3a8658682c
  style c5fcfb22_1acd_7d18_d142_3d656d477a03 fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

packages/astro/src/core/session/runtime.ts lines 259–301

	async [PERSIST_SYMBOL]() {
		// Handle session data persistence

		if (!this.#dirty && !this.#toDestroy.size) {
			return;
		}

		const storage = await this.#ensureStorage();

		if (this.#dirty && this.#data) {
			const data = await this.#ensureData();
			this.#toDelete.forEach((key) => data.delete(key));
			const key = this.#ensureSessionID();
			let serialized;
			try {
				serialized = stringify(data);
			} catch (err) {
				throw new AstroError(
					{
						...SessionStorageSaveError,
						message: SessionStorageSaveError.message(
							'The session data could not be serialized.',
							this.#config.driver,
						),
					},
					{ cause: err },
				);
			}
			await storage.setItem(key, serialized);
			this.#dirty = false;
		}

		// Handle destroyed session cleanup
		if (this.#toDestroy.size > 0) {
			const cleanupPromises = [...this.#toDestroy].map((sessionId) =>
				storage.removeItem(sessionId).catch((err) => {
					console.error(`Failed to clean up session ${sessionId}:`, err);
				}),
			);
			await Promise.all(cleanupPromises);
			this.#toDestroy.clear();
		}
	}

Domain

Subdomains

Calls

Frequently Asked Questions

What does PERSIST_SYMBOL() do?
PERSIST_SYMBOL() is a function in the astro codebase, defined in packages/astro/src/core/session/runtime.ts.
Where is PERSIST_SYMBOL() defined?
PERSIST_SYMBOL() is defined in packages/astro/src/core/session/runtime.ts at line 259.
What does PERSIST_SYMBOL() call?
PERSIST_SYMBOL() calls 1 function(s): stringify.

Analyze Your Own Codebase

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

Try Supermodel Free