From 32edd37f4d7494120f1a7eced782faa312c962b3 Mon Sep 17 00:00:00 2001 From: Steven Hall Date: Wed, 23 Apr 2025 16:25:50 +0100 Subject: [PATCH 1/3] Revert "Increase logging around caching behaviour causing page crashes. (#3182)" This reverts commit 97b7c79bc6a69ca6739b6e593e6f3b5b2f0c3c82. --- .changeset/sweet-schools-flow.md | 6 ------ packages/gitbook-v2/src/lib/context.ts | 20 +------------------- packages/gitbook/src/middleware.ts | 3 --- 3 files changed, 1 insertion(+), 28 deletions(-) delete mode 100644 .changeset/sweet-schools-flow.md diff --git a/.changeset/sweet-schools-flow.md b/.changeset/sweet-schools-flow.md deleted file mode 100644 index 6ff44bfa96..0000000000 --- a/.changeset/sweet-schools-flow.md +++ /dev/null @@ -1,6 +0,0 @@ ---- -"gitbook-v2": patch -"gitbook": patch ---- - -Increase logging around caching behaviour causing page crashes. diff --git a/packages/gitbook-v2/src/lib/context.ts b/packages/gitbook-v2/src/lib/context.ts index c85434c91f..7ef0f463b9 100644 --- a/packages/gitbook-v2/src/lib/context.ts +++ b/packages/gitbook-v2/src/lib/context.ts @@ -220,8 +220,6 @@ export async function fetchSiteContextByIds( ): Promise { const { dataFetcher } = baseContext; - const DEBUG = ids.site === 'site_cu2ih'; - const [{ site: orgSite, structure: siteStructure, customizations, scripts }, spaceContext] = await Promise.all([ throwIfDataError( @@ -234,22 +232,6 @@ export async function fetchSiteContextByIds( fetchSpaceContextByIds(baseContext, ids), ]); - DEBUG && console.log('ids', JSON.stringify(ids)); - DEBUG && - console.log( - 'siteStructure', - siteStructure - ? JSON.stringify({ - type: siteStructure.type, - structure: siteStructure.structure.map((s) => { - // @ts-ignore - const { siteSpaces, urls, ...rest } = s; - return rest; - }), - }) - : 'null' - ); - // override the title with the customization title // TODO: remove this hack once we have a proper way to handle site customizations const site = { @@ -425,7 +407,7 @@ export function checkIsRootSiteContext(context: GitBookSiteContext): boolean { function parseSiteSectionsAndGroups(structure: SiteStructure, siteSectionId: string) { const sectionsAndGroups = getSiteStructureSections(structure, { ignoreGroups: false }); const section = parseCurrentSection(structure, siteSectionId); - assert(section, `couldn't find section "${siteSectionId}" in site structure`); + assert(section, 'A section must be defined when there are multiple sections'); return { list: sectionsAndGroups, current: section } satisfies SiteSections; } diff --git a/packages/gitbook/src/middleware.ts b/packages/gitbook/src/middleware.ts index 0e599c4486..30f7b44e6a 100644 --- a/packages/gitbook/src/middleware.ts +++ b/packages/gitbook/src/middleware.ts @@ -674,9 +674,6 @@ async function lookupSiteByAPI( } ); - alternative.url.includes('minas-tirith') && - console.log(`resolved ${alternative.url} -> ${JSON.stringify(data)}`); - if ('error' in data) { if (alternative.primary) { // We only return an error for the primary alternative (full URL), From d1b1bd972493344c4991a8d3c49ebfb3f9fa350d Mon Sep 17 00:00:00 2001 From: Steven Hall Date: Wed, 23 Apr 2025 16:26:29 +0100 Subject: [PATCH 2/3] Changeset --- .changeset/young-games-talk.md | 6 ++++++ 1 file changed, 6 insertions(+) create mode 100644 .changeset/young-games-talk.md diff --git a/.changeset/young-games-talk.md b/.changeset/young-games-talk.md new file mode 100644 index 0000000000..096dc02060 --- /dev/null +++ b/.changeset/young-games-talk.md @@ -0,0 +1,6 @@ +--- +"gitbook": patch +"gitbook-v2": patch +--- + +Revert investigation work around URL caches. From 867d9ee9912ff6eac0f5adc0fe3956c44e9d8ae5 Mon Sep 17 00:00:00 2001 From: Steven Hall Date: Wed, 23 Apr 2025 16:28:13 +0100 Subject: [PATCH 3/3] re-add log --- .changeset/sweet-schools-flow.md | 6 ++++++ packages/gitbook-v2/src/lib/context.ts | 2 +- 2 files changed, 7 insertions(+), 1 deletion(-) create mode 100644 .changeset/sweet-schools-flow.md diff --git a/.changeset/sweet-schools-flow.md b/.changeset/sweet-schools-flow.md new file mode 100644 index 0000000000..6ff44bfa96 --- /dev/null +++ b/.changeset/sweet-schools-flow.md @@ -0,0 +1,6 @@ +--- +"gitbook-v2": patch +"gitbook": patch +--- + +Increase logging around caching behaviour causing page crashes. diff --git a/packages/gitbook-v2/src/lib/context.ts b/packages/gitbook-v2/src/lib/context.ts index 7ef0f463b9..22e25a5990 100644 --- a/packages/gitbook-v2/src/lib/context.ts +++ b/packages/gitbook-v2/src/lib/context.ts @@ -407,7 +407,7 @@ export function checkIsRootSiteContext(context: GitBookSiteContext): boolean { function parseSiteSectionsAndGroups(structure: SiteStructure, siteSectionId: string) { const sectionsAndGroups = getSiteStructureSections(structure, { ignoreGroups: false }); const section = parseCurrentSection(structure, siteSectionId); - assert(section, 'A section must be defined when there are multiple sections'); + assert(section, `couldn't find section "${siteSectionId}" in site structure`); return { list: sectionsAndGroups, current: section } satisfies SiteSections; }