(Created on )

Puppeteer: Expected value of header '{value}' to be String, but '{value}' is found.

An extra HTTP header value is not a string.


An extra HTTP header value is not a string.

Error message

Expected value of header '{value}' to be String, but '{value}' is found.

{value} is replaced by the value shown in your error message.

How this error happens

Extra HTTP headers must have string values. A number from your configuration is not converted automatically.

The snippets use an open Puppeteer page named page.

await page.setExtraHTTPHeaders({
    "x-retry-count": 3,
});

How to fix

Convert the value to a string before setting the headers.

const retryCount = 3;

await page.setExtraHTTPHeaders({
    "x-retry-count": String(retryCount),
});

Things to keep in mind

Validate missing values as well. String(undefined) produces a literal header value, not an omitted header.

All Puppeteer errors

Keep Reading

Puppeteer Guides

All Guides →