From 58595d696cb96ee538faac36c9b0bb557de69bfa Mon Sep 17 00:00:00 2001 From: nikitachapovskii-dev Date: Wed, 2 Sep 2026 16:19:17 +0200 Subject: [PATCH] fix(scraper-tools): restore saveSnapshot() under content-type v2 --- .../actor-scraper/web-scraper/src/internals/crawler_setup.ts | 4 ++-- packages/scraper-tools/src/context.ts | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/packages/actor-scraper/web-scraper/src/internals/crawler_setup.ts b/packages/actor-scraper/web-scraper/src/internals/crawler_setup.ts index b896e5b7..e50c62ef 100644 --- a/packages/actor-scraper/web-scraper/src/internals/crawler_setup.ts +++ b/packages/actor-scraper/web-scraper/src/internals/crawler_setup.ts @@ -24,7 +24,7 @@ import { import type { ApifyEnv } from 'apify'; import { Actor } from 'apify'; import type { HTTPResponse, Page } from 'puppeteer'; -import contentType from 'content-type'; +import { parse as parseContentType } from 'content-type'; // @ts-expect-error no typings import DevToolsServer from 'devtools-server'; import { getInjectableScript } from 'idcac-playwright'; @@ -660,7 +660,7 @@ export class CrawlerSetup implements CrawlerSetupOptions { const cTypeHeader = response.headers()['content-type']; try { - const { type } = contentType.parse(cTypeHeader); + const { type } = parseContentType(cTypeHeader); if (!/^(text|application)\/xml$|\+xml$/.test(type)) return; } catch { // Invalid type is not XML. diff --git a/packages/scraper-tools/src/context.ts b/packages/scraper-tools/src/context.ts index 80e5f3bf..ad1c7220 100644 --- a/packages/scraper-tools/src/context.ts +++ b/packages/scraper-tools/src/context.ts @@ -11,7 +11,7 @@ import type { Dictionary } from '@crawlee/utils'; import type { ApifyEnv } from 'apify'; import { Actor } from 'apify'; import type { ContentType } from 'content-type'; -import contentTypeParser from 'content-type'; +import { format as formatContentType } from 'content-type'; import log from '@apify/log'; @@ -114,7 +114,7 @@ class Context< return saveSnapshot({ page: this.page as SnapshotOptions['page'], body: this.body as SnapshotOptions['body'], - contentType: this.contentType ? contentTypeParser.format(this.contentType as ContentType) : null, + contentType: this.contentType ? formatContentType(this.contentType as ContentType) : null, json: this.json, }); }