mirror of
https://github.com/GitbookIO/gitbook.git
synced 2026-09-22 02:23:30 +00:00
Fix crash when resolving references without permissions (#212)
This commit is contained in:
Vendored
+14
-9
@@ -120,16 +120,21 @@ export function cache<Args extends any[], Result>(
|
||||
return cachedEntry[0].data;
|
||||
}
|
||||
|
||||
const fetched = await revalidate(key, ...args);
|
||||
console.log(
|
||||
`cache: ${key} miss in ${fetched.fetchDuration.toFixed(
|
||||
0,
|
||||
)}ms, read in ${readCacheDuration.toFixed(
|
||||
0,
|
||||
)}ms, write in ${fetched.writeCacheDuration.toFixed(0)}ms`,
|
||||
);
|
||||
try {
|
||||
const fetched = await revalidate(key, ...args);
|
||||
console.log(
|
||||
`cache: ${key} miss in ${fetched.fetchDuration.toFixed(
|
||||
0,
|
||||
)}ms, read in ${readCacheDuration.toFixed(
|
||||
0,
|
||||
)}ms, write in ${fetched.writeCacheDuration.toFixed(0)}ms`,
|
||||
);
|
||||
|
||||
return fetched.data;
|
||||
return fetched.data;
|
||||
} catch (error) {
|
||||
console.error(`cache: ${key} error: ${error}`);
|
||||
throw error;
|
||||
}
|
||||
},
|
||||
);
|
||||
};
|
||||
|
||||
@@ -175,8 +175,12 @@ async function resolveContentRefInSpace(spaceId: string, contentRef: ContentRef)
|
||||
spaceId,
|
||||
};
|
||||
|
||||
const [space, pages] = await Promise.all([getSpace(spaceId), getRevisionPages(pointer)]);
|
||||
const result = await ignoreError(Promise.all([getSpace(spaceId), getRevisionPages(pointer)]));
|
||||
if (!result) {
|
||||
return null;
|
||||
}
|
||||
|
||||
const [space, pages] = result;
|
||||
return resolveContentRef(contentRef, {
|
||||
content: pointer,
|
||||
space,
|
||||
|
||||
Reference in New Issue
Block a user