Skip to content

Commit

Permalink
Fix TimeoutError issue
Browse files Browse the repository at this point in the history
  • Loading branch information
enricoros committed May 18, 2024
1 parent 811875d commit 7c099ca
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions src/modules/browse/browse.router.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { z } from 'zod';
import { TRPCError } from '@trpc/server';

import { BrowserContext, connect, ScreenshotOptions, TimeoutError } from '@cloudflare/puppeteer';
import { BrowserContext, connect, ScreenshotOptions } from '@cloudflare/puppeteer';
import { default as TurndownService } from 'turndown';
import { load as cheerioLoad } from 'cheerio';

Expand Down Expand Up @@ -134,7 +134,8 @@ async function workerPuppeteer(
result.stopReason = 'end';
}
} catch (error: any) {
const isTimeout = error instanceof TimeoutError;
// This was "error instanceof TimeoutError;" but threw some type error - trying the below instead
const isTimeout = error?.message?.includes('Navigation timeout') || false;
result.stopReason = isTimeout ? 'timeout' : 'error';
if (!isTimeout) {
result.error = '[Puppeteer] ' + (error?.message || error?.toString() || 'Unknown goto error');
Expand Down

0 comments on commit 7c099ca

Please sign in to comment.