mirror of
https://github.com/GitbookIO/gitbook.git
synced 2026-09-24 03:16:40 +00:00
Increase logging around caching behaviour causing page crashes. (#3182)
This commit is contained in:
@@ -0,0 +1,6 @@
|
|||||||
|
---
|
||||||
|
"gitbook-v2": patch
|
||||||
|
"gitbook": patch
|
||||||
|
---
|
||||||
|
|
||||||
|
Increase logging around caching behaviour causing page crashes.
|
||||||
@@ -220,6 +220,8 @@ export async function fetchSiteContextByIds(
|
|||||||
): Promise<GitBookSiteContext> {
|
): Promise<GitBookSiteContext> {
|
||||||
const { dataFetcher } = baseContext;
|
const { dataFetcher } = baseContext;
|
||||||
|
|
||||||
|
const DEBUG = ids.site === 'site_cu2ih';
|
||||||
|
|
||||||
const [{ site: orgSite, structure: siteStructure, customizations, scripts }, spaceContext] =
|
const [{ site: orgSite, structure: siteStructure, customizations, scripts }, spaceContext] =
|
||||||
await Promise.all([
|
await Promise.all([
|
||||||
throwIfDataError(
|
throwIfDataError(
|
||||||
@@ -232,6 +234,22 @@ export async function fetchSiteContextByIds(
|
|||||||
fetchSpaceContextByIds(baseContext, ids),
|
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
|
// override the title with the customization title
|
||||||
// TODO: remove this hack once we have a proper way to handle site customizations
|
// TODO: remove this hack once we have a proper way to handle site customizations
|
||||||
const site = {
|
const site = {
|
||||||
@@ -407,7 +425,7 @@ export function checkIsRootSiteContext(context: GitBookSiteContext): boolean {
|
|||||||
function parseSiteSectionsAndGroups(structure: SiteStructure, siteSectionId: string) {
|
function parseSiteSectionsAndGroups(structure: SiteStructure, siteSectionId: string) {
|
||||||
const sectionsAndGroups = getSiteStructureSections(structure, { ignoreGroups: false });
|
const sectionsAndGroups = getSiteStructureSections(structure, { ignoreGroups: false });
|
||||||
const section = parseCurrentSection(structure, siteSectionId);
|
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;
|
return { list: sectionsAndGroups, current: section } satisfies SiteSections;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -674,6 +674,9 @@ async function lookupSiteByAPI(
|
|||||||
}
|
}
|
||||||
);
|
);
|
||||||
|
|
||||||
|
alternative.url.includes('minas-tirith') &&
|
||||||
|
console.log(`resolved ${alternative.url} -> ${JSON.stringify(data)}`);
|
||||||
|
|
||||||
if ('error' in data) {
|
if ('error' in data) {
|
||||||
if (alternative.primary) {
|
if (alternative.primary) {
|
||||||
// We only return an error for the primary alternative (full URL),
|
// We only return an error for the primary alternative (full URL),
|
||||||
|
|||||||
Reference in New Issue
Block a user