apify/crawlee · critical · Error

Can not parse mime type ${mimeType} from "options.additional

Error message

Can not parse mime type ${mimeType} from "options.additionalMimeTypes".

What it means

The constructor runs every entry of `additionalMimeTypes` through the content-type parser so it can map them to supported MIME types; if a value cannot be parsed (invalid string or object shape), it throws this error and the crawler never starts. This is a fail-fast configuration validation error.

Source

Thrown at packages/http-crawler/src/internals/http-crawler.ts:852

        throw new Error(`Resource ${request.url} served with unsupported charset/encoding: ${encoding}`);
    }

    /**
     * Checks and extends supported mime types
     */
    private extendSupportedMimeTypes(additionalMimeTypes: (string | RequestLike | ResponseLike)[]) {
        for (const mimeType of additionalMimeTypes) {
            if (mimeType === '*/*') {
                this.#supportedMimeTypes.add(mimeType);
                continue;
            }

            try {
                const parsedType = contentTypeParser.parse(mimeType);
                this.#supportedMimeTypes.add(parsedType.type);
            } catch (err) {
                throw new Error(`Can not parse mime type ${mimeType} from "options.additionalMimeTypes".`);
            }
        }
    }

    /**
     * Handles timeout request
     */
    private handleRequestTimeout(session: ISession) {
        session.markBad();
        throw new Error(`Request timed out after ${this.#navigationTimeoutMillis / 1000} seconds.`);
    }

    private abortDownloadOfBody(request: CrawleeRequest, response: Response) {
        const { status } = response;
        const { type } = parseContentTypeFromResponse(response);

        const isTransientContentType = status >= 500 || this.blockedStatusCodes.has(status);

View on GitHub (pinned to dbe57fb09c)

Solutions

  1. Use full valid MIME type strings: ['application/json', 'text/plain', 'application/xml'].
  2. Validate each entry with the same parser before constructing: `require('content-type').parse(value)` in a try/catch to find the offender.
  3. If passing objects, ensure they match the RequestLike/ResponseLike contract (must parse to a `.type`).
  4. Pass an array of strings, not one comma-separated string.

Example fix

// before
new HttpCrawler({ additionalMimeTypes: ['json', 'text/jason'] });

// after
new HttpCrawler({ additionalMimeTypes: ['application/json', 'application/atom+xml'] });
Defensive patterns

Strategy: validation

Validate before calling

import contentTypeParser from 'content-type';
function validateMimeTypes(types: (string | object)[]): void {
  for (const t of types) {
    try { contentTypeParser.parse(String(t)); }
    catch { throw new Error(`Invalid additionalMimeTypes entry: ${JSON.stringify(t)}`); }
  }
}
validateMimeTypes(['application/json', 'application/xml']);

Type guard

function isValidMimeType(v: unknown): v is string {
  if (typeof v !== 'string') return false;
  try { contentTypeParser.parse(v); return true; } catch { return false; }
}

Try / catch

try {
  const crawler = new HttpCrawler({ additionalMimeTypes: userTypes });
} catch (err) {
  if (err instanceof Error && err.message.includes('additionalMimeTypes')) {
    throw new Error(`Config error — fix options.additionalMimeTypes: ${err.message}`);
  }
  throw err;
}

Prevention

When it happens

Trigger: Passing malformed values in `options.additionalMimeTypes` — e.g. 'json' without a type, 'application/', an empty string, or an object lacking the required type/parse shape.

Common situations: Typing `'additionalMimeTypes': ['json']` instead of `'application/json'`; a comma-joined string instead of an array; mistyping a MIME like 'text/jason'; passing a RequestLike/ResponseLike object missing expected properties.

Related errors


AI-assisted analysis of apify/crawlee@dbe57fb09c (2026-08-30). Data as JSON: /api/errors/8e6a344ac9670e7f. Report an issue: GitHub.