Home / Function/ flush() — astro Function Reference

flush() — astro Function Reference

Architecture documentation for the flush() function in util.ts from the astro codebase.

Entity Profile

Dependency Diagram

graph TD
  87b072e3_880a_861b_20e6_451043e37f03["flush()"]
  48bba3f8_c792_f2aa_c497_4f494ca2f1da["BufferedRenderer"]
  87b072e3_880a_861b_20e6_451043e37f03 -->|defined in| 48bba3f8_c792_f2aa_c497_4f494ca2f1da
  8810f212_398f_b23a_f478_dead3b83984d["write()"]
  87b072e3_880a_861b_20e6_451043e37f03 -->|calls| 8810f212_398f_b23a_f478_dead3b83984d
  style 87b072e3_880a_861b_20e6_451043e37f03 fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

packages/astro/src/runtime/server/render/util.ts lines 226–244

	public flush(): void | Promise<void> {
		if (this.flushed) {
			throw new Error('The render buffer has already been flushed.');
		}

		this.flushed = true;

		// Write the buffered chunks to the real destination
		for (const chunk of this.chunks) {
			this.destination.write(chunk);
		}

		// NOTE: We don't empty `this.chunks` after it's written as benchmarks show
		// that it causes poorer performance, likely due to forced memory re-allocation,
		// instead of letting the garbage collector handle it automatically.
		// (Unsure how this affects on limited memory machines)

		return this.renderPromise;
	}

Domain

Subdomains

Calls

Frequently Asked Questions

What does flush() do?
flush() is a function in the astro codebase, defined in packages/astro/src/runtime/server/render/util.ts.
Where is flush() defined?
flush() is defined in packages/astro/src/runtime/server/render/util.ts at line 226.
What does flush() call?
flush() calls 1 function(s): write.

Analyze Your Own Codebase

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

Try Supermodel Free