Skip to content

Commit d3d0416

Browse files
committed
Revert "Investigate issue where icons and ogimage would occasionally fail. (#3099)"
This reverts commit f07982d.
1 parent 79638e7 commit d3d0416

File tree

5 files changed

+5
-38
lines changed

5 files changed

+5
-38
lines changed

packages/gitbook-v2/src/lib/links.ts

Lines changed: 1 addition & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -72,17 +72,6 @@ export function createLinker(
7272

7373
const siteBasePath = withTrailingSlash(withLeadingSlash(servedOn.siteBasePath));
7474
const spaceBasePath = withTrailingSlash(withLeadingSlash(servedOn.spaceBasePath));
75-
const protocol = (() => {
76-
if (servedOn.protocol) {
77-
return servedOn.protocol;
78-
}
79-
80-
if (servedOn.host) {
81-
return servedOn.host.startsWith('localhost') ? 'http:' : 'https:';
82-
}
83-
84-
return 'https:';
85-
})();
8675

8776
const linker: GitBookLinker = {
8877
toPathInSpace(relativePath: string): string {
@@ -108,7 +97,7 @@ export function createLinker(
10897
return absolutePath;
10998
}
11099

111-
return `${protocol}//${joinPaths(servedOn.host, absolutePath)}`;
100+
return `${servedOn.protocol ?? 'https:'}//${joinPaths(servedOn.host, absolutePath)}`;
112101
},
113102

114103
toPathForPage({ pages, page, anchor }) {

packages/gitbook/src/app/middleware/(site)/(core)/~gitbook/icon/route.tsx

Lines changed: 3 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -7,21 +7,8 @@ import { serveIcon } from '@/routes/icon';
77
export const runtime = 'edge';
88

99
export async function GET(req: NextRequest) {
10-
try {
11-
console.log('icon: getSiteContentPointer');
12-
const pointer = await getSiteContentPointer();
13-
console.log('icon: fetchV1context');
14-
const context = await fetchV1ContextForSitePointer(pointer);
10+
const pointer = await getSiteContentPointer();
11+
const context = await fetchV1ContextForSitePointer(pointer);
1512

16-
// biome-ignore lint/suspicious/noConsole: we want to log here
17-
console.log(`serving icon for ${context.site.id}`);
18-
19-
return await serveIcon(context, req);
20-
} catch (err) {
21-
if (err instanceof Error) {
22-
console.error(`icon: ${err.toString()}`, err.stack);
23-
}
24-
25-
throw err;
26-
}
13+
return serveIcon(context, req);
2714
}

packages/gitbook/src/lib/cache/cloudflare-do.ts

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -26,12 +26,7 @@ export const cloudflareDOCache: CacheBackend = {
2626
return null;
2727
}
2828

29-
try {
30-
return (await stub.get<CacheEntry>(key)) ?? null;
31-
} catch (err) {
32-
console.error('cloudflareDO.get', err);
33-
return null;
34-
}
29+
return (await stub.get<CacheEntry>(key)) ?? null;
3530
}
3631
);
3732
},

packages/gitbook/src/lib/v1.ts

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -285,7 +285,6 @@ async function getDataFetcherV1(): Promise<GitBookDataFetcher> {
285285
export async function fetchV1ContextForSitePointer(pointer: SiteContentPointer) {
286286
const baseContext = await getV1BaseContext();
287287

288-
console.log('icon: baseContext success');
289288
const context = await fetchSiteContextByIds(baseContext, {
290289
organization: pointer.organizationId,
291290
site: pointer.siteId,
@@ -296,10 +295,8 @@ export async function fetchV1ContextForSitePointer(pointer: SiteContentPointer)
296295
changeRequest: pointer.changeRequestId,
297296
revision: pointer.revisionId,
298297
});
299-
console.log('icon: context inner success');
300298

301299
context.customization = await getDynamicCustomizationSettings(context.customization);
302-
console.log('icon: customization success');
303300

304301
return context;
305302
}

packages/gitbook/src/routes/icon.tsx

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,6 @@ const SIZES = {
2727
* Generate an icon for a site content.
2828
*/
2929
export async function serveIcon(context: GitBookSiteContext, req: Request) {
30-
console.log('icon: serveIcon', req.url);
3130
const options = getOptions(req.url);
3231
const size = SIZES[options.size];
3332

0 commit comments

Comments
 (0)