Skip to content

Supercharge your AI agents with data from the web and beyond. Building the library for superintelligence. 🔥

refactor(api): remove fire-engine playwright engine (#3142)

tomsideguideebb3e9174325
diff --git a/apps/api/src/controllers/v2/types.ts b/apps/api/src/controllers/v2/types.ts
index a0e921eb5..30332c56d 100644
--- a/apps/api/src/controllers/v2/types.ts
+++ b/apps/api/src/controllers/v2/types.ts
@@ -405,7 +405,7 @@ const queryFormatWithOptions = z.strictObject({
prompt: z.string().max(10000),
});
-export type QueryFormatWithOptions = z.output<typeof queryFormatWithOptions>;
+type QueryFormatWithOptions = z.output<typeof queryFormatWithOptions>;
export type FormatObject =
| { type: "markdown" }
diff --git a/apps/api/src/scraper/WebScraper/utils/ENGINE_FORCING.md b/apps/api/src/scraper/WebScraper/utils/ENGINE_FORCING.md
index 5dfcbf155..978ca0791 100644
--- a/apps/api/src/scraper/WebScraper/utils/ENGINE_FORCING.md
+++ b/apps/api/src/scraper/WebScraper/utils/ENGINE_FORCING.md
@@ -27,10 +27,8 @@ The engine forcing is configured via the `FORCED_ENGINE_DOMAINS` environment var
### Available Engines
- `fire-engine;chrome-cdp` - Advanced browser with Chrome DevTools Protocol
-- `fire-engine;playwright` - Playwright-based browser automation
- `fire-engine;tlsclient` - TLS fingerprinting for anti-bot bypass
- `fire-engine;chrome-cdp;stealth` - Chrome CDP with stealth mode
-- `fire-engine;playwright;stealth` - Playwright with stealth mode
- `fire-engine;tlsclient;stealth` - TLS client with stealth mode
- `playwright` - Direct Playwright integration
- `fetch` - Simple HTTP requests
diff --git a/apps/api/src/scraper/scrapeURL/engines/fire-engine/checkStatus.ts b/apps/api/src/scraper/scrapeURL/engines/fire-engine/checkStatus.ts
index ca486e842..e062bd734 100644
--- a/apps/api/src/scraper/scrapeURL/engines/fire-engine/checkStatus.ts
+++ b/apps/api/src/scraper/scrapeURL/engines/fire-engine/checkStatus.ts
@@ -36,10 +36,6 @@ const successSchema = z.object({
// timeTakenCookie: z.number().optional(),
// timeTakenRequest: z.number().optional(),
- // legacy: playwright only
- screenshot: z.string().optional(),
-
- // new: actions
screenshots: z.string().array().optional(),
actionContent: z
.object({
diff --git a/apps/api/src/scraper/scrapeURL/engines/fire-engine/index.ts b/apps/api/src/scraper/scrapeURL/engines/fire-engine/index.ts
index 09d1a967d..e1652dcbf 100644
--- a/apps/api/src/scraper/scrapeURL/engines/fire-engine/index.ts
+++ b/apps/api/src/scraper/scrapeURL/engines/fire-engine/index.ts
@@ -6,7 +6,6 @@ import {
fireEngineStagingURL,
FireEngineScrapeRequestChromeCDP,
FireEngineScrapeRequestCommon,
- FireEngineScrapeRequestPlaywright,
FireEngineScrapeRequestTLSClient,
} from "./scrape";
import { EngineScrapeResult } from "..";
@@ -48,7 +47,6 @@ const BRANDING_DEFAULT_WAIT_MS = 2000;
async function performFireEngineScrape<
Engine extends
| FireEngineScrapeRequestChromeCDP
- | FireEngineScrapeRequestPlaywright
| FireEngineScrapeRequestTLSClient,
>(
meta: Meta,
@@ -244,7 +242,9 @@ async function performFireEngineScrape<
"fire-engine.duration_ms": Date.now() - startTime,
"fire-engine.status_code": status.pageStatusCode,
"fire-engine.content_length": status.content?.length,
- "fire-engine.has_screenshot": !!status.screenshot,
+ "fire-engine.has_screenshot": !!(
+ status.screenshots && status.screenshots.length > 0
+ ),
"fire-engine.has_pdf": !!(status as any).pdf,
"fire-engine.job_id": (scrape as any).jobId,
});
@@ -367,19 +367,12 @@ export async function scrapeURLWithFireEngineChromeCDP(
true,
);
+ let screenshot: string | undefined;
if (hasFormatOfType(meta.options.formats, "screenshot")) {
- // meta.logger.debug(
- // "Transforming screenshots from actions into screenshot field",
- // { screenshots: response.screenshots },
- // );
- if (response.screenshots) {
- response.screenshot = response.screenshots.slice(-1)[0];
+ if (response.screenshots && response.screenshots.length > 0) {
+ screenshot = response.screenshots.slice(-1)[0];
response.screenshots = response.screenshots.slice(0, -1);
}
- // meta.logger.debug("Screenshot transformation done", {
- // screenshots: response.screenshots,
- // screenshot: response.screenshot,
- // });
}
if (!response.url) {
@@ -435,7 +428,7 @@ export async function scrapeURLWithFireEngineChromeCDP(
x => x[0].toLowerCase() === "content-type",
) ?? [])[1] ?? undefined,
- screenshot: response.screenshot,
+ screenshot,
...(actions.length > 0
? {
actions: {
@@ -456,84 +449,6 @@ export async function scrapeURLWithFireEngineChromeCDP(
});
}
-export async function scrapeURLWithFireEnginePlaywright(
- meta: Meta,
-): Promise<EngineScrapeResult> {
- return withSpan("engine.fire-engine.playwright", async span => {
- setSpanAttributes(span, {
- "engine.type": "fire-engine-playwright",
- "engine.url": meta.url,
- "engine.team_id": meta.internalOptions.teamId,
- });
- const totalWait = meta.options.waitFor;
-
- const request: FireEngineScrapeRequestCommon &
- FireEngineScrapeRequestPlaywright = {
- url: meta.rewrittenUrl ?? meta.url,
- scrapeId: meta.id,
- engine: "playwright",
- instantReturn: false,
-
- headers: meta.options.headers,
- priority: meta.internalOptions.priority,
- screenshot:
- hasFormatOfType(meta.options.formats, "screenshot") !== undefined,
- fullPageScreenshot: hasFormatOfType(meta.options.formats, "screenshot")
- ?.fullPage,
- wait: meta.options.waitFor,
- geolocation: meta.options.location,
- blockAds: meta.options.blockAds,
- mobileProxy: meta.featureFlags.has("stealthProxy"),
-
- timeout: meta.abort.scrapeTimeout() ?? 300000,
- saveScrapeResultToGCS:
- !meta.internalOptions.zeroDataRetention &&
- meta.internalOptions.saveScrapeResultToGCS,
- zeroDataRetention: meta.internalOptions.zeroDataRetention,
- };
-
- let response = await performFireEngineScrape(
- meta,
- meta.logger.child({
- method: "scrapeURLWithFireEnginePlaywright/callFireEngine",
- request,
- }),
- request,
- meta.mock,
- meta.abort.asSignal(),
- );
-
- if (!response.url) {
- meta.logger.warn("Fire-engine did not return the response's URL", {
- response,
- sourceURL: meta.url,
- });
- }
-
- return {
- url: response.url ?? meta.url,
-
- html: response.content,
- error: response.pageError,
- statusCode: response.pageStatusCode,
-
- contentType:
- (Object.entries(response.responseHeaders ?? {}).find(
- x => x[0].toLowerCase() === "content-type",
- ) ?? [])[1] ?? undefined,
-
- ...(response.screenshots !== undefined && response.screenshots.length > 0
- ? {
- screenshot: response.screenshots[0],
- }
- : {}),
-
- proxyUsed: response.usedMobileProxy ? "stealth" : "basic",
- timezone: response.timezone,
- };
- });
-}
-
export async function scrapeURLWithFireEngineTLSClient(
meta: Meta,
): Promise<EngineScrapeResult> {
@@ -603,7 +518,7 @@ export async function scrapeURLWithFireEngineTLSClient(
export function fireEngineMaxReasonableTime(
meta: Meta,
- engine: "chrome-cdp" | "playwright" | "tlsclient",
+ engine: "chrome-cdp" | "tlsclient",
): number {
const hasBranding = hasFormatOfType(meta.options.formats, "branding");
const defaultWait = hasBranding ? BRANDING_DEFAULT_WAIT_MS : 0;
@@ -614,8 +529,6 @@ export function fireEngineMaxReasonableTime(
if (engine === "tlsclient") {
return 15000;
- } else if (engine === "playwright") {
- return (meta.options.waitFor ?? 0) + 30000;
} else {
return (
effectiveWait +
diff --git a/apps/api/src/scraper/scrapeURL/engines/fire-engine/scrape.ts b/apps/api/src/scraper/scrapeURL/engines/fire-engine/scrape.ts
index e100c7421..c7d80ce01 100644
--- a/apps/api/src/scraper/scrapeURL/engines/fire-engine/scrape.ts
+++ b/apps/api/src/scraper/scrapeURL/engines/fire-engine/scrape.ts
@@ -55,17 +55,6 @@ export type FireEngineScrapeRequestChromeCDP = {
disableSmartWaitCache?: boolean;
};
-export type FireEngineScrapeRequestPlaywright = {
- engine: "playwright";
- blockAds?: boolean; // default: true
-
- // mutually exclusive, default: false
- screenshot?: boolean;
- fullPageScreenshot?: boolean;
-
- wait?: number; // default: 0
-};
-
export type FireEngineScrapeRequestTLSClient = {
engine: "tlsclient";
atsv?: boolean; // v0 only, default: false
@@ -88,10 +77,6 @@ const successSchema = z.object({
// timeTakenCookie: z.number().optional(),
// timeTakenRequest: z.number().optional(),
- // legacy: playwright only
- screenshot: z.string().optional(),
-
- // new: actions
screenshots: z.string().array().optional(),
actionContent: z
.object({
@@ -176,7 +161,6 @@ export const fireEngineStagingURL =
export async function fireEngineScrape<
Engine extends
| FireEngineScrapeRequestChromeCDP
- | FireEngineScrapeRequestPlaywright
| FireEngineScrapeRequestTLSClient,
>(
meta: Meta,
diff --git a/apps/api/src/scraper/scrapeURL/engines/index.ts b/apps/api/src/scraper/scrapeURL/engines/index.ts
index 97765f6b3..3524f403d 100644
--- a/apps/api/src/scraper/scrapeURL/engines/index.ts
+++ b/apps/api/src/scraper/scrapeURL/engines/index.ts
@@ -5,7 +5,6 @@ import { documentMaxReasonableTime, scrapeDocument } from "./document";
import {
fireEngineMaxReasonableTime,
scrapeURLWithFireEngineChromeCDP,
- scrapeURLWithFireEnginePlaywright,
scrapeURLWithFireEngineTLSClient,
} from "./fire-engine";
import { pdfMaxReasonableTime, scrapePDF } from "./pdf";
@@ -32,8 +31,6 @@ export type Engine =
| "fire-engine(retry);chrome-cdp"
| "fire-engine;chrome-cdp;stealth"
| "fire-engine(retry);chrome-cdp;stealth"
- | "fire-engine;playwright"
- | "fire-engine;playwright;stealth"
| "fire-engine;tlsclient"
| "fire-engine;tlsclient;stealth"
| "playwright"
@@ -65,8 +62,6 @@ const engines: Engine[] = [
"fire-engine;chrome-cdp;stealth" as const,
"fire-engine(retry);chrome-cdp" as const,
"fire-engine(retry);chrome-cdp;stealth" as const,
- // "fire-engine;playwright" as const,
- // "fire-engine;playwright;stealth" as const,
"fire-engine;tlsclient" as const,
"fire-engine;tlsclient;stealth" as const,
]
@@ -162,8 +157,6 @@ const engineHandlers: {
"fire-engine(retry);chrome-cdp": scrapeURLWithFireEngineChromeCDP,
"fire-engine;chrome-cdp;stealth": scrapeURLWithFireEngineChromeCDP,
"fire-engine(retry);chrome-cdp;stealth": scrapeURLWithFireEngineChromeCDP,
- "fire-engine;playwright": scrapeURLWithFireEnginePlaywright,
- "fire-engine;playwright;stealth": scrapeURLWithFireEnginePlaywright,
"fire-engine;tlsclient": scrapeURLWithFireEngineTLSClient,
"fire-engine;tlsclient;stealth": scrapeURLWithFireEngineTLSClient,
playwright: scrapeURLWithPlaywright,
@@ -186,10 +179,6 @@ const engineMRTs: {
fireEngineMaxReasonableTime(meta, "chrome-cdp"),
"fire-engine(retry);chrome-cdp;stealth": meta =>
fireEngineMaxReasonableTime(meta, "chrome-cdp"),
- "fire-engine;playwright": meta =>
- fireEngineMaxReasonableTime(meta, "playwright"),
- "fire-engine;playwright;stealth": meta =>
- fireEngineMaxReasonableTime(meta, "playwright"),
"fire-engine;tlsclient": meta =>
fireEngineMaxReasonableTime(meta, "tlsclient"),
"fire-engine;tlsclient;stealth": meta =>
@@ -325,44 +314,6 @@ const engineOptions: {
},
quality: -5,
},
- "fire-engine;playwright": {
- features: {
- actions: false,
- waitFor: true,
- screenshot: true,
- "screenshot@fullScreen": true,
- pdf: false,
- document: false,
- atsv: false,
- location: false,
- mobile: false,
- skipTlsVerification: false,
- useFastMode: false,
- stealthProxy: false,
- branding: false,
- disableAdblock: true,
- },
- quality: 40,
- },
- "fire-engine;playwright;stealth": {
- features: {
- actions: false,
- waitFor: true,
- screenshot: true,
- "screenshot@fullScreen": true,
- pdf: false,
- document: false,
- atsv: false,
- location: false,
- mobile: false,
- skipTlsVerification: false,
- useFastMode: false,
- stealthProxy: true,
- branding: false,
- disableAdblock: true,
- },
- quality: -10,
- },
playwright: {
features: {
actions: false,
@@ -543,9 +494,7 @@ export async function buildFallbackList(meta: Meta): Promise<
"fire-engine(retry);chrome-cdp",
"fire-engine;chrome-cdp;stealth",
"fire-engine(retry);chrome-cdp;stealth",
- "fire-engine;playwright",
// "fire-engine;tlsclient",
- // "fire-engine;playwright;stealth",
// "fire-engine;tlsclient;stealth",
] as Engine[])
: []),
diff --git a/apps/api/src/scraper/scrapeURL/lib/urlSpecificParams.ts b/apps/api/src/scraper/scrapeURL/lib/urlSpecificParams.ts
index fca2526e2..143d34cf0 100644
--- a/apps/api/src/scraper/scrapeURL/lib/urlSpecificParams.ts
+++ b/apps/api/src/scraper/scrapeURL/lib/urlSpecificParams.ts
@@ -32,14 +32,6 @@ export const urlSpecificParams: Record<string, UrlSpecificParams> = {
// },
// },
// },
- // "notion.com": {
- // scrapeOptions: { waitFor: 2000 },
- // internalOptions: { forceEngine: "fire-engine;playwright" }
- // },
- // "developer.apple.com": {
- // scrapeOptions: { waitFor: 2000 },
- // internalOptions: { forceEngine: "fire-engine;playwright" }
- // },
"digikey.com": {
scrapeOptions: {},
internalOptions: { forceEngine: "fire-engine;tlsclient" },
diff --git a/apps/api/src/scraper/scrapeURL/scrapeURL.test.ts b/apps/api/src/scraper/scrapeURL/scrapeURL.test.ts
index f183df28e..19ddba04e 100644
--- a/apps/api/src/scraper/scrapeURL/scrapeURL.test.ts
+++ b/apps/api/src/scraper/scrapeURL/scrapeURL.test.ts
@@ -22,7 +22,6 @@ import { parseMarkdown } from "../../lib/html-to-markdown";
const testEngines: (Engine | undefined)[] = [
undefined,
"fire-engine;chrome-cdp",
- "fire-engine;playwright",
"fire-engine;tlsclient",
"fetch",
];
@@ -30,7 +29,6 @@ const testEngines: (Engine | undefined)[] = [
const testEnginesScreenshot: (Engine | undefined)[] = [
undefined,
"fire-engine;chrome-cdp",
- "fire-engine;playwright",
];
describe("Standalone scrapeURL tests", () => {
diff --git a/apps/api/src/services/ab-test.ts b/apps/api/src/services/ab-test.ts
index ae5c302ca..4efee3390 100644
--- a/apps/api/src/services/ab-test.ts
+++ b/apps/api/src/services/ab-test.ts
@@ -5,7 +5,6 @@ import { config } from "../config";
import {
FireEngineScrapeRequestChromeCDP,
FireEngineScrapeRequestCommon,
- FireEngineScrapeRequestPlaywright,
FireEngineScrapeRequestTLSClient,
} from "../scraper/scrapeURL/engines/fire-engine/scrape";
import { getDocFromGCS } from "../lib/gcs-jobs";
@@ -80,11 +79,7 @@ type ABTestDecision =
export function abTestFireEngine(
feRequest: FireEngineScrapeRequestCommon &
- (
- | FireEngineScrapeRequestChromeCDP
- | FireEngineScrapeRequestPlaywright
- | FireEngineScrapeRequestTLSClient
- ),
+ (FireEngineScrapeRequestChromeCDP | FireEngineScrapeRequestTLSClient),
): ABTestDecision {
const abLogger = _logger.child({ method: "ABTestFireEngine" });