Comparing version 5.13.4 to 5.13.5
@@ -141,27 +141,2 @@ "use strict"; | ||
} | ||
if ((0, _enginesHelpers.shouldGenerateEngines)()) { | ||
const state = _redux.store.getState(); | ||
const buildActivityTimer = _reporter.default.activityTimer(`Building Rendering Engines`, { | ||
parentSpan: buildSpan | ||
}); | ||
try { | ||
buildActivityTimer.start(); | ||
// bundle graphql-engine | ||
engineBundlingPromises.push((0, _bundleWebpack.createGraphqlEngineBundle)(program.directory, _reporter.default, program.verbose)); | ||
engineBundlingPromises.push((0, _bundleWebpack2.createPageSSRBundle)({ | ||
rootDir: program.directory, | ||
components: state.components, | ||
staticQueriesByTemplate: state.staticQueriesByTemplate, | ||
webpackCompilationHash: webpackCompilationHash, | ||
// we set webpackCompilationHash above | ||
reporter: _reporter.default, | ||
isVerbose: program.verbose | ||
})); | ||
await Promise.all(engineBundlingPromises); | ||
} catch (err) { | ||
_reporter.default.panic(err); | ||
} finally { | ||
buildActivityTimer.end(); | ||
} | ||
} | ||
const buildSSRBundleActivityProgress = _reporter.default.activityTimer(`Building HTML renderer`, { | ||
@@ -230,2 +205,25 @@ parentSpan: buildSpan | ||
if ((0, _enginesHelpers.shouldGenerateEngines)()) { | ||
const state = _redux.store.getState(); | ||
const buildActivityTimer = _reporter.default.activityTimer(`Building Rendering Engines`, { | ||
parentSpan: buildSpan | ||
}); | ||
try { | ||
buildActivityTimer.start(); | ||
// bundle graphql-engine | ||
engineBundlingPromises.push((0, _bundleWebpack.createGraphqlEngineBundle)(program.directory, _reporter.default, program.verbose)); | ||
engineBundlingPromises.push((0, _bundleWebpack2.createPageSSRBundle)({ | ||
rootDir: program.directory, | ||
components: state.components, | ||
staticQueriesByTemplate: state.staticQueriesByTemplate, | ||
webpackCompilationHash: webpackCompilationHash, | ||
// we set webpackCompilationHash above | ||
reporter: _reporter.default, | ||
isVerbose: program.verbose | ||
})); | ||
await Promise.all(engineBundlingPromises); | ||
} catch (err) { | ||
_reporter.default.panic(err); | ||
} finally { | ||
buildActivityTimer.end(); | ||
} | ||
await (0, _validateEngines.validateEnginesWithActivity)(program.directory, buildSpan); | ||
@@ -232,0 +230,0 @@ } |
@@ -139,3 +139,4 @@ "use strict"; | ||
renderPageData, | ||
renderHTML | ||
renderHTML, | ||
findEnginePageByPath | ||
} = require(pageSSRModule); | ||
@@ -151,3 +152,3 @@ const graphqlEngine = new GraphQLEngine({ | ||
const potentialPagePath = (0, _pageData.reverseFixedPagePath)(requestedPagePath); | ||
const page = graphqlEngine.findPageByPath(potentialPagePath); | ||
const page = findEnginePageByPath(potentialPagePath); | ||
if (page && (page.mode === `DSG` || page.mode === `SSR`)) { | ||
@@ -190,3 +191,3 @@ const requestActivity = _reporter.default.phantomActivity(`request for "${req.path}"`); | ||
const potentialPagePath = req.path; | ||
const page = graphqlEngine.findPageByPath(potentialPagePath); | ||
const page = findEnginePageByPath(potentialPagePath); | ||
if (page && (page.mode === `DSG` || page.mode === `SSR`)) { | ||
@@ -193,0 +194,0 @@ const requestActivity = _reporter.default.phantomActivity(`request for "${req.path}"`); |
@@ -15,2 +15,5 @@ import "./bootstrap"; | ||
runQuery(query: string | Source, context?: Record<string, any>, opts?: IQueryOptions): Promise<ExecutionResult>; | ||
/** | ||
* @deprecated use findEnginePageByPath exported from page-ssr module instead | ||
*/ | ||
findPageByPath(pathName: string): IGatsbyPage | undefined; | ||
@@ -17,0 +20,0 @@ } |
@@ -179,2 +179,6 @@ "use strict"; | ||
} | ||
/** | ||
* @deprecated use findEnginePageByPath exported from page-ssr module instead | ||
*/ | ||
findPageByPath(pathName) { | ||
@@ -181,0 +185,0 @@ // adapter so `findPageByPath` use SitePage nodes in datastore |
import type { IGatsbyFunction, IGatsbyPage } from "../../redux/types"; | ||
export declare function getRoutePathFromPage(page: IGatsbyPage): string; | ||
export declare function getRoutePathFromPage(page: Pick<IGatsbyPage, "path" | "matchPath">): string; | ||
export declare function getRoutePathFromFunction(functionInfo: IGatsbyFunction): string; |
@@ -148,3 +148,3 @@ "use strict"; | ||
// handle lmdb file | ||
const mdbInPublicPath = `public/${_enginesHelpers.LmdbOnCdnPath}`; | ||
const mdbInPublicPath = `public/${(0, _enginesHelpers.getLmdbOnCdnPath)()}`; | ||
if (!(0, _enginesHelpers.shouldBundleDatastore)()) { | ||
@@ -151,0 +151,0 @@ const mdbPath = (0, _lmdbDatastore.getDefaultDbPath)() + `/data.mdb`; |
export declare function shouldPrintEngineSnapshot(): boolean; | ||
export declare function shouldGenerateEngines(): boolean; | ||
export declare function shouldBundleDatastore(): boolean; | ||
export declare const LmdbOnCdnPath: string; | ||
export declare const getLmdbOnCdnPath: () => string; | ||
export interface IPlatformAndArch { | ||
@@ -6,0 +6,0 @@ platform: string; |
"use strict"; | ||
exports.__esModule = true; | ||
exports.LmdbOnCdnPath = void 0; | ||
exports.getCurrentPlatformAndTarget = getCurrentPlatformAndTarget; | ||
exports.getFunctionsTargetPlatformAndTarget = getFunctionsTargetPlatformAndTarget; | ||
exports.getLmdbOnCdnPath = void 0; | ||
exports.shouldBundleDatastore = shouldBundleDatastore; | ||
@@ -37,4 +37,4 @@ exports.shouldGenerateEngines = shouldGenerateEngines; | ||
} | ||
const LmdbOnCdnPath = getCDNObfuscatedPath(`data.mdb`); | ||
exports.LmdbOnCdnPath = LmdbOnCdnPath; | ||
const getLmdbOnCdnPath = () => getCDNObfuscatedPath(`data.mdb`); | ||
exports.getLmdbOnCdnPath = getLmdbOnCdnPath; | ||
const currentTarget = { | ||
@@ -41,0 +41,0 @@ platform: process.platform, |
@@ -18,3 +18,3 @@ import type { Request } from "express"; | ||
} | ||
export declare function getServerData(req: Partial<Pick<Request, "query" | "method" | "url" | "headers">> | undefined, page: IGatsbyPage, pagePath: string, mod: IModuleWithServerData | undefined): Promise<IServerData>; | ||
export declare function getServerData(req: Partial<Pick<Request, "query" | "method" | "url" | "headers">> | undefined, page: Pick<IGatsbyPage, "path" | "matchPath" | "context">, pagePath: string, mod: IModuleWithServerData | undefined): Promise<IServerData>; | ||
export {}; |
@@ -15,2 +15,3 @@ "use strict"; | ||
var _enginesHelpers = require("../engines-helpers"); | ||
var _pageMode = require("../page-mode"); | ||
function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function (nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); } | ||
@@ -82,2 +83,17 @@ function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; } | ||
} | ||
const pagesIterable = []; | ||
for (const [pagePath, page] of state.pages) { | ||
const mode = (0, _pageMode.getPageMode)(page, state); | ||
if (mode !== `SSG`) { | ||
pagesIterable.push([pagePath, { | ||
componentChunkName: page.componentChunkName, | ||
componentPath: page.componentPath, | ||
context: page.context, | ||
matchPath: page.matchPath, | ||
mode, | ||
path: page.path, | ||
slices: page.slices | ||
}]); | ||
} | ||
} | ||
const compiler = (0, _webpack.default)({ | ||
@@ -157,2 +173,3 @@ name: `Page Engine`, | ||
WEBPACK_COMPILATION_HASH: JSON.stringify(webpackCompilationHash), | ||
GATSBY_PAGES: JSON.stringify(pagesIterable), | ||
GATSBY_SLICES: JSON.stringify(slicesStateObject), | ||
@@ -178,3 +195,3 @@ GATSBY_SLICES_BY_TEMPLATE: JSON.stringify(slicesByTemplateStateObject), | ||
let functionCode = await fs.readFile(path.join(__dirname, `lambda.js`), `utf-8`); | ||
functionCode = functionCode.replaceAll(`%CDN_DATASTORE_PATH%`, (0, _enginesHelpers.shouldBundleDatastore)() ? `` : `${(_state$adapter$config = state.adapter.config.deployURL) !== null && _state$adapter$config !== void 0 ? _state$adapter$config : ``}/${_enginesHelpers.LmdbOnCdnPath}`).replaceAll(`%PATH_PREFIX%`, pathPrefix).replaceAll(`%IMAGE_CDN_URL_GENERATOR_MODULE_RELATIVE_PATH%`, IMAGE_CDN_URL_GENERATOR_MODULE_RELATIVE_PATH).replaceAll(`%FILE_CDN_URL_GENERATOR_MODULE_RELATIVE_PATH%`, FILE_CDN_URL_GENERATOR_MODULE_RELATIVE_PATH); | ||
functionCode = functionCode.replaceAll(`%CDN_DATASTORE_PATH%`, (0, _enginesHelpers.shouldBundleDatastore)() ? `` : (0, _enginesHelpers.getLmdbOnCdnPath)()).replaceAll(`%CDN_DATASTORE_ORIGIN%`, (0, _enginesHelpers.shouldBundleDatastore)() ? `` : (_state$adapter$config = state.adapter.config.deployURL) !== null && _state$adapter$config !== void 0 ? _state$adapter$config : ``).replaceAll(`%PATH_PREFIX%`, pathPrefix).replaceAll(`%IMAGE_CDN_URL_GENERATOR_MODULE_RELATIVE_PATH%`, IMAGE_CDN_URL_GENERATOR_MODULE_RELATIVE_PATH).replaceAll(`%FILE_CDN_URL_GENERATOR_MODULE_RELATIVE_PATH%`, FILE_CDN_URL_GENERATOR_MODULE_RELATIVE_PATH); | ||
await fs.outputFile(path.join(outputDir, `lambda.js`), functionCode); | ||
@@ -181,0 +198,0 @@ return new Promise((resolve, reject) => { |
@@ -15,5 +15,6 @@ import "../engines-fs-provider"; | ||
} | ||
export type EnginePage = Pick<IGatsbyPage, "componentChunkName" | "componentPath" | "context" | "matchPath" | "mode" | "path" | "slices">; | ||
export interface ISSRData { | ||
results: IExecutionResult; | ||
page: IGatsbyPage; | ||
page: EnginePage; | ||
templateDetails: ITemplateDetails; | ||
@@ -34,5 +35,5 @@ potentialPagePath: string; | ||
const GATSBY_SLICES_SCRIPT: string; | ||
const GATSBY_PAGES: Array<[string, EnginePage]>; | ||
} | ||
export declare function getData({ pathName, graphqlEngine, req, spanContext, telemetryResolverTimings, }: { | ||
graphqlEngine: GraphQLEngine; | ||
interface IGetDataBaseArgs { | ||
pathName: string; | ||
@@ -42,3 +43,11 @@ req?: Partial<Pick<Request, "query" | "method" | "url" | "headers">>; | ||
telemetryResolverTimings?: Array<IGraphQLTelemetryRecord>; | ||
}): Promise<ISSRData>; | ||
} | ||
interface IGetDataEagerEngineArgs extends IGetDataBaseArgs { | ||
graphqlEngine: GraphQLEngine; | ||
} | ||
interface IGetDataLazyEngineArgs extends IGetDataBaseArgs { | ||
getGraphqlEngine: () => Promise<GraphQLEngine>; | ||
} | ||
type IGetDataArgs = IGetDataEagerEngineArgs | IGetDataLazyEngineArgs; | ||
export declare function getData(arg: IGetDataArgs): Promise<ISSRData>; | ||
export declare function renderPageData({ data, spanContext, }: { | ||
@@ -53,1 +62,3 @@ data: ISSRData; | ||
}): Promise<string>; | ||
export declare function findEnginePageByPath(pathName: string): EnginePage | undefined; | ||
export {}; |
@@ -5,2 +5,3 @@ "use strict"; | ||
exports.__esModule = true; | ||
exports.findEnginePageByPath = findEnginePageByPath; | ||
exports.getData = getData; | ||
@@ -21,2 +22,3 @@ exports.renderHTML = renderHTML; | ||
var _getRoutePath = require("../adapter/get-route-path"); | ||
var _findPageByPath = require("../find-page-by-path"); | ||
var _process$env$GATSBY_O; | ||
@@ -27,9 +29,13 @@ function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function (nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); } | ||
const createHeaders = (0, _createHeaders.createHeadersMatcher)(INLINED_HEADERS_CONFIG); | ||
async function getData({ | ||
pathName, | ||
graphqlEngine, | ||
req, | ||
spanContext, | ||
telemetryResolverTimings | ||
}) { | ||
function isEagerGraphqlEngine(arg) { | ||
return typeof arg.graphqlEngine !== `undefined`; | ||
} | ||
async function getData(arg) { | ||
const getGraphqlEngine = isEagerGraphqlEngine(arg) ? () => Promise.resolve(arg.graphqlEngine) : arg.getGraphqlEngine; | ||
const { | ||
pathName, | ||
req, | ||
spanContext, | ||
telemetryResolverTimings | ||
} = arg; | ||
await tracerReadyPromise; | ||
@@ -59,3 +65,3 @@ let getDataWrapperActivity; | ||
// 1. Find a page for pathname | ||
const maybePage = graphqlEngine.findPageByPath(potentialPagePath); | ||
const maybePage = findEnginePageByPath(potentialPagePath); | ||
if (!maybePage) { | ||
@@ -84,3 +90,2 @@ // page not found, nothing to run query for | ||
if (templateDetails.query) { | ||
var _runningQueryActivity; | ||
let runningQueryActivity; | ||
@@ -93,25 +98,28 @@ if (getDataWrapperActivity) { | ||
} | ||
executionPromises.push(graphqlEngine.runQuery(templateDetails.query, { | ||
...page, | ||
...page.context | ||
}, { | ||
queryName: page.path, | ||
componentPath: page.componentPath, | ||
parentSpan: (_runningQueryActivity = runningQueryActivity) === null || _runningQueryActivity === void 0 ? void 0 : _runningQueryActivity.span, | ||
forceGraphqlTracing: !!runningQueryActivity, | ||
telemetryResolverTimings | ||
}).then(queryResults => { | ||
if (queryResults.errors && queryResults.errors.length > 0) { | ||
const e = queryResults.errors[0]; | ||
const codeFrame = (0, _graphqlErrorsCodeframe.getCodeFrame)(templateDetails.query, e.locations && e.locations[0].line, e.locations && e.locations[0].column); | ||
const queryRunningError = new Error(e.message + `\n\n` + codeFrame); | ||
queryRunningError.stack = e.stack; | ||
throw queryRunningError; | ||
} else { | ||
results = queryResults; | ||
} | ||
}).finally(() => { | ||
if (runningQueryActivity) { | ||
runningQueryActivity.end(); | ||
} | ||
executionPromises.push(getGraphqlEngine().then(graphqlEngine => { | ||
var _runningQueryActivity; | ||
return graphqlEngine.runQuery(templateDetails.query, { | ||
...page, | ||
...page.context | ||
}, { | ||
queryName: page.path, | ||
componentPath: page.componentPath, | ||
parentSpan: (_runningQueryActivity = runningQueryActivity) === null || _runningQueryActivity === void 0 ? void 0 : _runningQueryActivity.span, | ||
forceGraphqlTracing: !!runningQueryActivity, | ||
telemetryResolverTimings | ||
}).then(queryResults => { | ||
if (queryResults.errors && queryResults.errors.length > 0) { | ||
const e = queryResults.errors[0]; | ||
const codeFrame = (0, _graphqlErrorsCodeframe.getCodeFrame)(templateDetails.query, e.locations && e.locations[0].line, e.locations && e.locations[0].column); | ||
const queryRunningError = new Error(e.message + `\n\n` + codeFrame); | ||
queryRunningError.stack = e.stack; | ||
throw queryRunningError; | ||
} else { | ||
results = queryResults; | ||
} | ||
}).finally(() => { | ||
if (runningQueryActivity) { | ||
runningQueryActivity.end(); | ||
} | ||
}); | ||
})); | ||
@@ -336,2 +344,8 @@ } | ||
} | ||
const stateWithPages = { | ||
pages: new Map(GATSBY_PAGES) | ||
}; | ||
function findEnginePageByPath(pathName) { | ||
return (0, _findPageByPath.findPageByPath)(stateWithPages, pathName, false); | ||
} | ||
//# sourceMappingURL=entry.js.map |
@@ -16,3 +16,6 @@ "use strict"; | ||
function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; } | ||
const cdnDatastore = `%CDN_DATASTORE_PATH%`; | ||
const cdnDatastorePath = `%CDN_DATASTORE_PATH%`; | ||
// this is fallback origin, we will prefer to extract it from first request instead | ||
// as in some cases one reported by adapter might not be correct | ||
const cdnDatastoreOrigin = `%CDN_DATASTORE_ORIGIN%`; | ||
const PATH_PREFIX = `%PATH_PREFIX%`; | ||
@@ -144,3 +147,3 @@ function setupFsWrapper() { | ||
global._fsWrapper = lfs; | ||
if (!cdnDatastore) { | ||
if (!cdnDatastorePath) { | ||
const dir = `data`; | ||
@@ -182,3 +185,4 @@ if (!process.env.NETLIFY_LOCAL && fs.existsSync(path.join(TEMP_CACHE_DIR, dir))) { | ||
renderPageData, | ||
renderHTML | ||
renderHTML, | ||
findEnginePageByPath | ||
} = require(`./index`); | ||
@@ -189,26 +193,39 @@ const streamPipeline = (0, _util.promisify)(_stream.pipeline); | ||
} | ||
async function getEngine() { | ||
if (cdnDatastore) { | ||
// if this variable is set we need to download the datastore from the CDN | ||
const downloadPath = dbPath + `/data.mdb`; | ||
console.log(`Downloading datastore from CDN (${cdnDatastore} -> ${downloadPath})`); | ||
await fs.ensureDir(dbPath); | ||
await new Promise((resolve, reject) => { | ||
const req = get(cdnDatastore, response => { | ||
if (!response.statusCode || response.statusCode < 200 || response.statusCode > 299) { | ||
reject(new Error(`Failed to download ${cdnDatastore}: ${response.statusCode} ${response.statusMessage || ``}`)); | ||
return; | ||
} | ||
const fileStream = fs.createWriteStream(downloadPath); | ||
streamPipeline(response, fileStream).then(resolve).catch(error => { | ||
console.log(`Error downloading ${cdnDatastore}`, error); | ||
reject(error); | ||
}); | ||
}); | ||
req.on(`error`, error => { | ||
function shouldDownloadDatastoreFromCDN() { | ||
return !!cdnDatastorePath; | ||
} | ||
async function downloadDatastoreFromCDN(origin) { | ||
const cdnDatastore = `${origin}/${cdnDatastorePath}`; | ||
// if this variable is set we need to download the datastore from the CDN | ||
const downloadPath = dbPath + `/data.mdb`; | ||
console.log(`Downloading datastore from CDN (${cdnDatastore} -> ${downloadPath})`); | ||
await fs.ensureDir(dbPath); | ||
await new Promise((resolve, reject) => { | ||
const req = get(cdnDatastore, response => { | ||
if (!response.statusCode || response.statusCode < 200 || response.statusCode > 299) { | ||
const engineError = new Error(`Failed to download ${cdnDatastore}: ${response.statusCode} ${response.statusMessage || ``}`); | ||
engineError.downloadError = true; | ||
reject(engineError); | ||
return; | ||
} | ||
const fileStream = fs.createWriteStream(downloadPath); | ||
streamPipeline(response, fileStream).then(resolve).catch(error => { | ||
console.log(`Error downloading ${cdnDatastore}`, error); | ||
reject(error); | ||
const engineError = error; | ||
engineError.downloadError = true; | ||
reject(engineError); | ||
}); | ||
}); | ||
console.log(`Downloaded datastore from CDN`); | ||
req.on(`error`, error => { | ||
console.log(`Error downloading ${cdnDatastore}`, error); | ||
const engineError = error; | ||
engineError.downloadError = true; | ||
reject(engineError); | ||
}); | ||
}); | ||
console.log(`Downloaded datastore from CDN`); | ||
} | ||
async function initializeGraphqlEngine(origin) { | ||
if (shouldDownloadDatastoreFromCDN()) { | ||
await downloadDatastoreFromCDN(origin); | ||
} | ||
@@ -221,3 +238,43 @@ const graphqlEngine = new GraphQLEngine({ | ||
} | ||
const engineReadyPromise = getEngine(); | ||
let memoizedGraphqlEnginePromise = null; | ||
const originToGraphqlEnginePromise = new Map(); | ||
function tryToInitializeGraphqlEngineFromCollectedOrigins() { | ||
for (const [origin, originEngineState] of originToGraphqlEnginePromise) { | ||
if (!(originEngineState instanceof Error)) { | ||
if (originEngineState === null) { | ||
const engineForOriginPromise = initializeGraphqlEngine(origin).catch(e => { | ||
originToGraphqlEnginePromise.set(origin, e instanceof Error ? e : new Error(e)); | ||
if (e.downloadError) { | ||
return tryToInitializeGraphqlEngineFromCollectedOrigins(); | ||
} | ||
throw e; | ||
}); | ||
originToGraphqlEnginePromise.set(origin, engineForOriginPromise); | ||
return engineForOriginPromise; | ||
} else { | ||
return originEngineState; | ||
} | ||
} | ||
} | ||
return Promise.reject(new Error(`No engine available`)); | ||
} | ||
function memoizedInitializeGraphqlEngine(origin) { | ||
if (!originToGraphqlEnginePromise.has(origin)) { | ||
// register origin, but for now don't init anything | ||
originToGraphqlEnginePromise.set(origin, null); | ||
} | ||
if (!memoizedGraphqlEnginePromise) { | ||
// pick first non-errored entry | ||
memoizedGraphqlEnginePromise = tryToInitializeGraphqlEngineFromCollectedOrigins().catch(e => { | ||
// at this point we don't have any origin that work, but maybe we will get one in future | ||
// so unset memoizedGraphqlEnginePromise as it would be not allowing any more attempts once it settled | ||
memoizedGraphqlEnginePromise = null; | ||
throw e; | ||
}); | ||
} | ||
return memoizedGraphqlEnginePromise; | ||
} | ||
memoizedInitializeGraphqlEngine(cdnDatastoreOrigin).catch(() => | ||
// we don't want to crash the process if we can't get the engine without a request | ||
null); | ||
function reverseFixedPagePath(pageDataRequestPath) { | ||
@@ -267,3 +324,3 @@ return pageDataRequestPath === `index` ? `/` : pageDataRequestPath; | ||
} | ||
function getPage(pathname, graphqlEngine) { | ||
function getPage(pathname) { | ||
const pathInfo = getPathInfo(pathname); | ||
@@ -277,3 +334,3 @@ if (!pathInfo) { | ||
} = pathInfo; | ||
const page = graphqlEngine.findPageByPath(pagePath); | ||
const page = findEnginePageByPath(pagePath); | ||
if (!page) { | ||
@@ -291,3 +348,2 @@ return undefined; | ||
var _req$url; | ||
const graphqlEngine = await engineReadyPromise; | ||
let pageInfo; | ||
@@ -297,6 +353,6 @@ const originalPathName = (_req$url = req.url) !== null && _req$url !== void 0 ? _req$url : ``; | ||
const maybePath = originalPathName.slice(PATH_PREFIX.length); | ||
pageInfo = getPage(maybePath, graphqlEngine); | ||
pageInfo = getPage(maybePath); | ||
} | ||
if (!pageInfo) { | ||
pageInfo = getPage(originalPathName, graphqlEngine); | ||
pageInfo = getPage(originalPathName); | ||
} | ||
@@ -314,3 +370,3 @@ if (!pageInfo) { | ||
pathName: pagePath, | ||
graphqlEngine, | ||
getGraphqlEngine: () => memoizedInitializeGraphqlEngine(req !== null && req !== void 0 && req.rawUrl ? new _url.URL(req.rawUrl).origin : cdnDatastoreOrigin), | ||
req | ||
@@ -317,0 +373,0 @@ }); |
@@ -1872,2 +1872,6 @@ import * as React from "react" | ||
cookies: Record<string, string> | ||
/** | ||
* Optional field to store the full raw URL by adapters | ||
*/ | ||
rawUrl?: string | ||
} | ||
@@ -1874,0 +1878,0 @@ |
{ | ||
"name": "gatsby", | ||
"description": "Blazing fast modern site generator for React", | ||
"version": "5.13.4", | ||
"version": "5.13.5", | ||
"author": "Kyle Mathews <mathews.kyle@gmail.com>", | ||
@@ -40,3 +40,3 @@ "bin": { | ||
"@typescript-eslint/parser": "^5.60.1", | ||
"@vercel/webpack-asset-relocator-loader": "^1.7.3", | ||
"@vercel/webpack-asset-relocator-loader": "1.7.3", | ||
"acorn-loose": "^8.3.0", | ||
@@ -283,3 +283,3 @@ "acorn-walk": "^8.2.0", | ||
}, | ||
"gitHead": "8f0f7c586e253a88673433deef26da84790944a1" | ||
"gitHead": "6c633505f4e2930119af6e7a442050cae52da9e7" | ||
} |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
7004041
70728
+ Added@types/node@22.8.2(transitive)
+ Added@vercel/webpack-asset-relocator-loader@1.7.3(transitive)
- Removed@babel/helper-builder-binary-assignment-operator-visitor@7.25.9(transitive)
- Removed@babel/helper-create-regexp-features-plugin@7.25.9(transitive)
- Removed@babel/helper-remap-async-to-generator@7.25.9(transitive)
- Removed@babel/helper-simple-access@7.25.9(transitive)
- Removed@msgpackr-extract/msgpackr-extract-linux-arm@3.0.3(transitive)
- Removed@msgpackr-extract/msgpackr-extract-linux-arm64@3.0.3(transitive)
- Removed@types/node@22.8.1(transitive)
- Removed@vercel/webpack-asset-relocator-loader@1.7.4(transitive)
- Removedcss-declaration-sorter@6.4.1(transitive)
- Removedcssnano-utils@3.1.0(transitive)
- Removedpostcss-calc@8.2.4(transitive)
- Removedpostcss-convert-values@5.1.3(transitive)
- Removedpostcss-discard-comments@5.1.2(transitive)
- Removedpostcss-discard-duplicates@5.1.0(transitive)
- Removedregenerator-transform@0.15.2(transitive)