veryfront 0.1.832 → 0.1.833
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/esm/deno.js +1 -1
- package/esm/src/proxy/main.js +3 -2
- package/esm/src/proxy/response-headers.d.ts +2 -0
- package/esm/src/proxy/response-headers.d.ts.map +1 -0
- package/esm/src/proxy/response-headers.js +74 -0
- package/esm/src/rendering/orchestrator/pipeline.d.ts.map +1 -1
- package/esm/src/rendering/orchestrator/pipeline.js +25 -23
- package/esm/src/utils/version-constant.d.ts +1 -1
- package/esm/src/utils/version-constant.js +1 -1
- package/package.json +1 -1
package/esm/deno.js
CHANGED
package/esm/src/proxy/main.js
CHANGED
|
@@ -38,6 +38,7 @@ import { handleReleaseAssetRequest, isReleaseAssetPath } from "./asset-handler.j
|
|
|
38
38
|
import { runProxyRequestLifecycle } from "./request-lifecycle.js";
|
|
39
39
|
import { createUpstreamFailureResponse, createUpstreamTimeoutResponse, UPSTREAM_FAILURE_STATUS, UPSTREAM_TIMEOUT_STATUS, } from "./upstream-error-response.js";
|
|
40
40
|
import { createProxyServerTiming, markProxyServerTimingPhase, profileProxyServerTimingPhase, withProxyServerTimingHeader, } from "./server-timing.js";
|
|
41
|
+
import { removeStickyCookieFromPublicCacheableResponse } from "./response-headers.js";
|
|
41
42
|
function getLocalProjects() {
|
|
42
43
|
const raw = getEnv("LOCAL_PROJECTS");
|
|
43
44
|
return raw ? JSON.parse(raw) : {};
|
|
@@ -335,11 +336,11 @@ function forwardToServer(req, url) {
|
|
|
335
336
|
else {
|
|
336
337
|
reqLogger.info(`${response.status} ${req.method} ${url.pathname}`, { ms });
|
|
337
338
|
}
|
|
338
|
-
return withProxyTiming(new Response(response.body, {
|
|
339
|
+
return withProxyTiming(removeStickyCookieFromPublicCacheableResponse(new Response(response.body, {
|
|
339
340
|
status: response.status,
|
|
340
341
|
statusText: response.statusText,
|
|
341
342
|
headers: response.headers,
|
|
342
|
-
}));
|
|
343
|
+
})));
|
|
343
344
|
}
|
|
344
345
|
catch (error) {
|
|
345
346
|
clearTimeout(timeoutId);
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"response-headers.d.ts","sourceRoot":"","sources":["../../../src/src/proxy/response-headers.ts"],"names":[],"mappings":"AA+DA,wBAAgB,6CAA6C,CAAC,QAAQ,EAAE,QAAQ,GAAG,QAAQ,CAkB1F"}
|
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
const STICKY_COOKIE_NAME = "lb";
|
|
2
|
+
function parseCacheControl(cacheControl) {
|
|
3
|
+
const directives = new Map();
|
|
4
|
+
if (!cacheControl)
|
|
5
|
+
return directives;
|
|
6
|
+
for (const part of cacheControl.split(",")) {
|
|
7
|
+
const trimmed = part.trim();
|
|
8
|
+
if (!trimmed)
|
|
9
|
+
continue;
|
|
10
|
+
const [rawName, rawValue] = trimmed.split("=", 2);
|
|
11
|
+
const name = rawName?.trim().toLowerCase();
|
|
12
|
+
if (!name)
|
|
13
|
+
continue;
|
|
14
|
+
directives.set(name, rawValue === undefined ? true : rawValue.trim().replace(/^"|"$/g, ""));
|
|
15
|
+
}
|
|
16
|
+
return directives;
|
|
17
|
+
}
|
|
18
|
+
function readPositiveDirectiveSeconds(directives, name) {
|
|
19
|
+
const value = directives.get(name);
|
|
20
|
+
if (typeof value !== "string")
|
|
21
|
+
return 0;
|
|
22
|
+
const seconds = Number(value);
|
|
23
|
+
return Number.isFinite(seconds) && seconds > 0 ? seconds : 0;
|
|
24
|
+
}
|
|
25
|
+
function isPublicCacheable(headers) {
|
|
26
|
+
const directives = parseCacheControl(headers.get("cache-control"));
|
|
27
|
+
if (!directives.has("public"))
|
|
28
|
+
return false;
|
|
29
|
+
if (directives.has("private") || directives.has("no-store") || directives.has("no-cache")) {
|
|
30
|
+
return false;
|
|
31
|
+
}
|
|
32
|
+
return directives.has("immutable") ||
|
|
33
|
+
readPositiveDirectiveSeconds(directives, "s-maxage") > 0 ||
|
|
34
|
+
readPositiveDirectiveSeconds(directives, "max-age") > 0;
|
|
35
|
+
}
|
|
36
|
+
function readSetCookies(headers) {
|
|
37
|
+
const getSetCookie = headers.getSetCookie;
|
|
38
|
+
if (typeof getSetCookie === "function") {
|
|
39
|
+
const values = getSetCookie.call(headers);
|
|
40
|
+
if (values.length > 0)
|
|
41
|
+
return values;
|
|
42
|
+
}
|
|
43
|
+
const values = [];
|
|
44
|
+
for (const [key, value] of headers) {
|
|
45
|
+
if (key.toLowerCase() === "set-cookie")
|
|
46
|
+
values.push(value);
|
|
47
|
+
}
|
|
48
|
+
const directValue = headers.get("set-cookie");
|
|
49
|
+
if (values.length === 0 && directValue)
|
|
50
|
+
values.push(directValue);
|
|
51
|
+
return values;
|
|
52
|
+
}
|
|
53
|
+
function isStickyCookie(setCookie) {
|
|
54
|
+
const [name] = setCookie.split("=", 1);
|
|
55
|
+
return name?.trim().toLowerCase() === STICKY_COOKIE_NAME;
|
|
56
|
+
}
|
|
57
|
+
export function removeStickyCookieFromPublicCacheableResponse(response) {
|
|
58
|
+
if (!isPublicCacheable(response.headers))
|
|
59
|
+
return response;
|
|
60
|
+
const setCookies = readSetCookies(response.headers);
|
|
61
|
+
if (setCookies.length === 0 || !setCookies.some(isStickyCookie))
|
|
62
|
+
return response;
|
|
63
|
+
const headers = new Headers(response.headers);
|
|
64
|
+
headers.delete("set-cookie");
|
|
65
|
+
for (const setCookie of setCookies) {
|
|
66
|
+
if (!isStickyCookie(setCookie))
|
|
67
|
+
headers.append("Set-Cookie", setCookie);
|
|
68
|
+
}
|
|
69
|
+
return new Response(response.body, {
|
|
70
|
+
status: response.status,
|
|
71
|
+
statusText: response.statusText,
|
|
72
|
+
headers,
|
|
73
|
+
});
|
|
74
|
+
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"pipeline.d.ts","sourceRoot":"","sources":["../../../../src/src/rendering/orchestrator/pipeline.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;
|
|
1
|
+
{"version":3,"file":"pipeline.d.ts","sourceRoot":"","sources":["../../../../src/src/rendering/orchestrator/pipeline.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAwBH,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,iCAAiC,CAAC;AAEtE,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,+BAA+B,CAAC;AACvE,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,qBAAqB,CAAC;AACxD,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,6BAA6B,CAAC;AAChE,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,aAAa,CAAC;AACtD,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,uBAAuB,CAAC;AAC7D,OAAO,KAAK,EAAE,gBAAgB,EAAE,aAAa,EAAE,YAAY,EAAE,MAAM,YAAY,CAAC;AA+ChF,OAAO,EAAE,wBAAwB,EAAE,MAAM,gBAAgB,CAAC;AAE1D;;;;GAIG;AACH,MAAM,WAAW,wBAAwB;IACvC,UAAU,CAAC,IAAI,EAAE,MAAM,EAAE,QAAQ,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC,iBAAiB,CAAC,CAAC;IACxE,aAAa,CAAC,MAAM,EAAE,YAAY,EAAE,IAAI,EAAE,MAAM,EAAE,QAAQ,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;CACrF;AAED,MAAM,WAAW,oBAAoB;IACnC,YAAY,EAAE,YAAY,CAAC;IAC3B,gBAAgB,EAAE,wBAAwB,CAAC;IAC3C,YAAY,EAAE,YAAY,CAAC;IAC3B,kBAAkB,EAAE,kBAAkB,CAAC;IACvC,eAAe,EAAE,eAAe,CAAC;IACjC,OAAO,EAAE,cAAc,CAAC;IACxB,IAAI,EAAE,aAAa,GAAG,YAAY,CAAC;IACnC,UAAU,EAAE,MAAM,CAAC;IACnB,8EAA8E;IAC9E,iBAAiB,CAAC,EAAE,OAAO,qBAAqB,EAAE,sBAAsB,CAAC;CAC1E;AA0BD,qBAAa,cAAc;IACzB,OAAO,CAAC,MAAM,CAAuB;IACrC,OAAO,CAAC,WAAW,CAAc;IACjC,OAAO,CAAC,kBAAkB,CAAqB;gBAEnC,MAAM,EAAE,oBAAoB;IAaxC;;;OAGG;IACH,gBAAgB,IAAI,IAAI;IAKxB,OAAO,CAAC,UAAU;YAIJ,0BAA0B;IAaxC;;;;;;;;;OASG;YACW,qBAAqB;IAyDnC;;;OAGG;YACW,mBAAmB;IA8GjC,OAAO,CAAC,uBAAuB;IAkCzB,UAAU,CAAC,IAAI,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,aAAa,GAAG,OAAO,CAAC,YAAY,CAAC;IAsS9E,+EAA+E;IACzE,eAAe,CAAC,IAAI,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,aAAa,GAAG,OAAO,CAAC,gBAAgB,CAAC;YAiGzE,kBAAkB;YA2ClB,cAAc;IAW5B,OAAO,CAAC,uBAAuB;YAYjB,kBAAkB;IAyFhC,OAAO,CAAC,kBAAkB;YAQZ,uBAAuB;IAmBrC;;;;;;OAMG;IACH,OAAO,CAAC,aAAa;CAStB"}
|
|
@@ -17,6 +17,7 @@ import { rendererLogger as logger } from "../../utils/index.js";
|
|
|
17
17
|
import { getExtensionName } from "../../utils/path-utils.js";
|
|
18
18
|
import { createBuildVersion } from "../../utils/version.js";
|
|
19
19
|
import { withSpan } from "../../observability/tracing/otlp-setup.js";
|
|
20
|
+
import { profilePhase } from "../../observability/request-profiler.js";
|
|
20
21
|
import { SpanNames } from "../../observability/tracing/span-names.js";
|
|
21
22
|
import { VeryfrontError } from "../../errors/index.js";
|
|
22
23
|
import { FILE_NOT_FOUND, RENDER_ERROR } from "../../errors/error-registry.js";
|
|
@@ -178,12 +179,12 @@ export class RenderPipeline {
|
|
|
178
179
|
if (modulesToLoad.length === 0) {
|
|
179
180
|
return { params, pageProps, layoutProps };
|
|
180
181
|
}
|
|
181
|
-
const loadedModules = await withSpan(SpanNames.RENDER_LOAD_MODULES, () => withTimeoutThrow(this.loadModulesInParallel(modulesToLoad), MODULE_LOAD_TIMEOUT_MS, `Module loading for ${slug}`), { "render.module_count": modulesToLoad.length });
|
|
182
|
+
const loadedModules = await profilePhase("render.load_modules", () => withSpan(SpanNames.RENDER_LOAD_MODULES, () => withTimeoutThrow(this.loadModulesInParallel(modulesToLoad), MODULE_LOAD_TIMEOUT_MS, `Module loading for ${slug}`), { "render.module_count": modulesToLoad.length }));
|
|
182
183
|
const dataJobs = loadedModules.filter((m) => hasDataFetchingFunction(m.mod));
|
|
183
184
|
if (dataJobs.length === 0) {
|
|
184
185
|
return { params, pageProps, layoutProps };
|
|
185
186
|
}
|
|
186
|
-
const dataResults = await withSpan(SpanNames.RENDER_FETCH_DATA, () => withTimeoutThrow(Promise.all(dataJobs.map(async (job) => {
|
|
187
|
+
const dataResults = await profilePhase("render.fetch_data", () => withSpan(SpanNames.RENDER_FETCH_DATA, () => withTimeoutThrow(Promise.all(dataJobs.map(async (job) => {
|
|
187
188
|
try {
|
|
188
189
|
const jobPath = job.path;
|
|
189
190
|
const fetchOptions = {
|
|
@@ -197,7 +198,7 @@ export class RenderPipeline {
|
|
|
197
198
|
catch (error) {
|
|
198
199
|
return { ...job, result: null, error: error };
|
|
199
200
|
}
|
|
200
|
-
})), DATA_FETCH_TIMEOUT_MS, `Data fetch for ${slug}`), { "render.data_job_count": dataJobs.length });
|
|
201
|
+
})), DATA_FETCH_TIMEOUT_MS, `Data fetch for ${slug}`), { "render.data_job_count": dataJobs.length }));
|
|
201
202
|
this.applyFetchedDataResults(slug, dataResults, pageProps, layoutProps);
|
|
202
203
|
return { params, pageProps, layoutProps };
|
|
203
204
|
}
|
|
@@ -255,13 +256,13 @@ export class RenderPipeline {
|
|
|
255
256
|
const renderOnce = () => withSpan("render.page", async () => {
|
|
256
257
|
const { result } = await runWithCSSCollector(async () => {
|
|
257
258
|
const pageResolveStart = performance.now();
|
|
258
|
-
const pageInfo = await withSpan("render.resolve_page", () => this.config.pageResolver.resolvePage(slug), { "render.slug": slug });
|
|
259
|
+
const pageInfo = await profilePhase("render.resolve_page", () => withSpan("render.resolve_page", () => this.config.pageResolver.resolvePage(slug), { "render.slug": slug }));
|
|
259
260
|
timing.pageResolve = Math.round(performance.now() - pageResolveStart);
|
|
260
261
|
const sourceFile = extractRelativePathShared(pageInfo.entity.path, this.config.projectDir);
|
|
261
262
|
try {
|
|
262
263
|
const skipLayouts = isDotPath(slug, pageInfo.entity.path);
|
|
263
264
|
const layoutCollectStart = performance.now();
|
|
264
|
-
const layoutResult = skipLayouts ? EMPTY_LAYOUT_RESULT : await withSpan("render.collect_layouts", () => this.config.layoutOrchestrator.collectLayouts(pageInfo), { "render.slug": slug });
|
|
265
|
+
const layoutResult = skipLayouts ? EMPTY_LAYOUT_RESULT : await profilePhase("render.collect_layouts", () => withSpan("render.collect_layouts", () => this.config.layoutOrchestrator.collectLayouts(pageInfo), { "render.slug": slug }));
|
|
265
266
|
timing.layoutCollect = Math.round(performance.now() - layoutCollectStart);
|
|
266
267
|
const layoutPreloadPromise = !skipLayouts && layoutResult.nestedLayouts.length > 0
|
|
267
268
|
? this.config.layoutOrchestrator.preloadLayoutModules(layoutResult.nestedLayouts)
|
|
@@ -273,7 +274,7 @@ export class RenderPipeline {
|
|
|
273
274
|
let layoutDataMap = new Map();
|
|
274
275
|
const dataFetchStart = performance.now();
|
|
275
276
|
if (options?.request && options?.url) {
|
|
276
|
-
await withSpan("render.data_fetching", async () => {
|
|
277
|
+
await profilePhase("render.data_fetching", () => withSpan("render.data_fetching", async () => {
|
|
277
278
|
try {
|
|
278
279
|
const dataResolution = await this.resolveDataFetching(slug, pageInfo.entity.path, layoutResult.nestedLayouts, options);
|
|
279
280
|
resolvedParams = dataResolution.params;
|
|
@@ -291,7 +292,7 @@ export class RenderPipeline {
|
|
|
291
292
|
});
|
|
292
293
|
throw error;
|
|
293
294
|
}
|
|
294
|
-
}, { "render.slug": slug });
|
|
295
|
+
}, { "render.slug": slug }));
|
|
295
296
|
}
|
|
296
297
|
timing.dataFetch = Math.round(performance.now() - dataFetchStart);
|
|
297
298
|
const hasResolvedParams = Object.keys(resolvedParams).length > 0;
|
|
@@ -305,7 +306,7 @@ export class RenderPipeline {
|
|
|
305
306
|
}
|
|
306
307
|
: options;
|
|
307
308
|
const bundlePrepStart = performance.now();
|
|
308
|
-
const pageBundleResult = await withSpan("render.prepare_bundles", () => this.config.pageRenderer.preparePageBundles(pageInfo, slug, cacheResult?.cachedModule, mergedOptions), { "render.slug": slug });
|
|
309
|
+
const pageBundleResult = await profilePhase("render.prepare_bundles", () => withSpan("render.prepare_bundles", () => this.config.pageRenderer.preparePageBundles(pageInfo, slug, cacheResult?.cachedModule, mergedOptions), { "render.slug": slug }));
|
|
309
310
|
timing.bundlePrep = Math.round(performance.now() - bundlePrepStart);
|
|
310
311
|
if (pageBundleResult.scriptResult)
|
|
311
312
|
return pageBundleResult.scriptResult;
|
|
@@ -323,13 +324,16 @@ export class RenderPipeline {
|
|
|
323
324
|
const headings = pageBundle.headings || [];
|
|
324
325
|
await layoutPreloadPromise;
|
|
325
326
|
const layoutApplyStart = performance.now();
|
|
326
|
-
const wrappedElement = await withSpan("render.apply_layouts", () => this.config.layoutOrchestrator.applyLayoutsAndWrappers(pageElement, pageInfo, layoutResult.layoutBundle, layoutResult.nestedLayouts, layoutDataMap, options?.url, resolvedParams, mergedFrontmatter, headings, options?.projectSlug), {
|
|
327
|
+
const wrappedElement = await profilePhase("render.apply_layouts", () => withSpan("render.apply_layouts", () => this.config.layoutOrchestrator.applyLayoutsAndWrappers(pageElement, pageInfo, layoutResult.layoutBundle, layoutResult.nestedLayouts, layoutDataMap, options?.url, resolvedParams, mergedFrontmatter, headings, options?.projectSlug), {
|
|
328
|
+
"render.slug": slug,
|
|
329
|
+
"render.layout_count": layoutResult.nestedLayouts.length,
|
|
330
|
+
}));
|
|
327
331
|
timing.layoutApply = Math.round(performance.now() - layoutApplyStart);
|
|
328
332
|
// Snapshot CSS imports collected during module loading (before SSR rendering).
|
|
329
333
|
// These are passed to the HTML generator to be included in the output.
|
|
330
334
|
const collectedCSSImports = getCSSImports();
|
|
331
335
|
const ssrStart = performance.now();
|
|
332
|
-
const ssrResult = await withSpan("render.ssr", () => withTimeoutThrow(this.config.ssrOrchestrator.performSSRRendering(wrappedElement, {
|
|
336
|
+
const ssrResult = await profilePhase("render.ssr", () => withSpan("render.ssr", () => withTimeoutThrow(this.config.ssrOrchestrator.performSSRRendering(wrappedElement, {
|
|
333
337
|
pageInfo,
|
|
334
338
|
pageBundle,
|
|
335
339
|
layoutBundle: layoutResult.layoutBundle,
|
|
@@ -337,7 +341,7 @@ export class RenderPipeline {
|
|
|
337
341
|
collectedMetadata: pageBundleResult.collectedMetadata,
|
|
338
342
|
slug,
|
|
339
343
|
cssImports: collectedCSSImports,
|
|
340
|
-
}, mergedOptions), SSR_RENDER_TIMEOUT_MS, `SSR rendering for ${slug}`), { "render.slug": slug, "render.delivery": mergedOptions?.delivery || "full" });
|
|
344
|
+
}, mergedOptions), SSR_RENDER_TIMEOUT_MS, `SSR rendering for ${slug}`), { "render.slug": slug, "render.delivery": mergedOptions?.delivery || "full" }));
|
|
341
345
|
timing.ssr = Math.round(performance.now() - ssrStart);
|
|
342
346
|
if (collectedCSSImports.length > 0) {
|
|
343
347
|
renderPipelineLog.debug("CSS imports collected for HTML generation", {
|
|
@@ -411,24 +415,22 @@ export class RenderPipeline {
|
|
|
411
415
|
if (this.config.mode === "development") {
|
|
412
416
|
clearSSRModuleCacheForProject(projectId);
|
|
413
417
|
}
|
|
414
|
-
const pageInfo = await this.config.pageResolver.resolvePage(slug);
|
|
418
|
+
const pageInfo = await profilePhase("page_data.resolve_page", () => this.config.pageResolver.resolvePage(slug));
|
|
415
419
|
const skipLayouts = isDotPath(slug, pageInfo.entity.path);
|
|
416
|
-
const layoutResult = skipLayouts
|
|
417
|
-
? EMPTY_LAYOUT_RESULT
|
|
418
|
-
: await this.config.layoutOrchestrator.collectLayouts(pageInfo);
|
|
420
|
+
const layoutResult = skipLayouts ? EMPTY_LAYOUT_RESULT : await profilePhase("page_data.collect_layouts", () => this.config.layoutOrchestrator.collectLayouts(pageInfo));
|
|
419
421
|
const pagePath = extractRelativePathShared(pageInfo.entity.path, this.config.projectDir);
|
|
420
422
|
const fileExtension = getExtensionName(pageInfo.entity.path);
|
|
421
423
|
const pageType = fileExtension;
|
|
422
|
-
const dataResolution = await this.resolveDataFetching(slug, pageInfo.entity.path, layoutResult.nestedLayouts, options);
|
|
424
|
+
const dataResolution = await profilePhase("page_data.resolve_data", () => this.resolveDataFetching(slug, pageInfo.entity.path, layoutResult.nestedLayouts, options));
|
|
423
425
|
const pageProps = dataResolution.pageProps;
|
|
424
426
|
const params = dataResolution.params;
|
|
425
427
|
const layoutProps = serializeLayoutProps(dataResolution.layoutProps);
|
|
426
|
-
const { frontmatter, headings } = await this.extractMdxMetadata(pageType, pageInfo, slug, options, params);
|
|
428
|
+
const { frontmatter, headings } = await profilePhase("page_data.extract_mdx_metadata", () => this.extractMdxMetadata(pageType, pageInfo, slug, options, params));
|
|
427
429
|
const layouts = serializeLayouts(layoutResult.nestedLayouts, this.config.projectDir);
|
|
428
430
|
const providers = [];
|
|
429
431
|
const projectUpdatedAt = this.resolveProjectUpdatedAt();
|
|
430
|
-
const appPath = await this.resolveAppPath();
|
|
431
|
-
const { css, cssAction, cssError } = await this.resolvePageDataCss(slug, options, projectUpdatedAt);
|
|
432
|
+
const appPath = await profilePhase("page_data.resolve_app_path", () => this.resolveAppPath());
|
|
433
|
+
const { css, cssAction, cssError } = await profilePhase("page_data.resolve_css", () => this.resolvePageDataCss(slug, options, projectUpdatedAt));
|
|
432
434
|
resolvePageDataLog.debug("Resolved page data", {
|
|
433
435
|
slug,
|
|
434
436
|
pagePath,
|
|
@@ -515,17 +517,17 @@ export class RenderPipeline {
|
|
|
515
517
|
return { css: cachedCss, cssAction: undefined, cssError: undefined };
|
|
516
518
|
}
|
|
517
519
|
try {
|
|
518
|
-
const renderResult = await withTimeout(this.renderPage(slug, {
|
|
520
|
+
const renderResult = await profilePhase("page_data.css.render_html", () => withTimeout(this.renderPage(slug, {
|
|
519
521
|
...options,
|
|
520
522
|
delivery: "string",
|
|
521
523
|
skipCacheCheck: true,
|
|
522
524
|
skipCachePersist: true,
|
|
523
|
-
}), CSS_SSR_TIMEOUT_MS, `CSS SSR for ${slug}`);
|
|
525
|
+
}), CSS_SSR_TIMEOUT_MS, `CSS SSR for ${slug}`));
|
|
524
526
|
if (!renderResult?.html) {
|
|
525
527
|
return { css: undefined, cssAction: undefined, cssError: undefined };
|
|
526
528
|
}
|
|
527
529
|
let cssAction;
|
|
528
|
-
let css = await this.resolveCssFromRenderedHtml(renderResult.html, options?.projectSlug ?? options?.projectId);
|
|
530
|
+
let css = await profilePhase("page_data.css.extract_from_html", () => this.resolveCssFromRenderedHtml(renderResult.html, options?.projectSlug ?? options?.projectId));
|
|
529
531
|
if (css) {
|
|
530
532
|
resolvePageDataLog.debug("Reused SSR CSS for page data", {
|
|
531
533
|
slug,
|
|
@@ -540,7 +542,7 @@ export class RenderPipeline {
|
|
|
540
542
|
});
|
|
541
543
|
}
|
|
542
544
|
else {
|
|
543
|
-
css = await this.generatePageCssFromHtml(slug, renderResult.html, options);
|
|
545
|
+
css = await profilePhase("page_data.css.generate_from_html", () => this.generatePageCssFromHtml(slug, renderResult.html, options));
|
|
544
546
|
}
|
|
545
547
|
if (css)
|
|
546
548
|
cachePageCss(cssCacheKey, css);
|