Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 6 additions & 13 deletions packages/kit/src/runtime/server/page/render.js
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ export async function render_response({
const inline_styles = new Map();

// TODO `svelte/server` should expose `RenderOutput`
/** @type {{ head: string, body: string, hashes: { script: string[] } }} */
/** @type {Omit<Awaited<ReturnType<typeof render>>, 'html'>} */
let rendered;

const form_value =
Expand Down Expand Up @@ -244,19 +244,12 @@ export async function render_response({
}

rendered = await with_request_store({ event, state: render_state }, async () => {
// We have to invoke .then eagerly here in order to kick off rendering: it's only starting on access,
// and `await maybe_promise` would eagerly access the .then property but call its function only after a tick, which is too late
// for the paths.reset() below and for any eager getRequestEvent() calls during rendering without AsyncLocalStorage available.
const rendered = render(Root, { ...render_opts, props });

const { head, body, hashes } = await rendered;

if (hashes) {
csp.add_script_hashes(hashes.script);
}

return { head, body, hashes };
return render(Root, { ...render_opts, props });
});

if (rendered.hashes) {
csp.add_script_hashes(rendered.hashes.script);
}
} finally {
if (DEV) {
globalThis.fetch = fetch;
Expand Down
Loading