Rayrun
← Back to Discord Forum

Max Size for page.evaluate(fn,args) parameters

I am invoking page.evaluate with a function, and am passing in a very large string.

This is working great

const tocOutside = await page.evaluate(async (base64Buffer) => {
...
}, base64Buffer);

But in a few cases, I am getting:

Error: page.evaluate: Execution context was destroyed, most likely because of a navigation.

It seems to be related to the payload size.

Is there a maximum size to the passed parameter, in my case it seem to fail at about 126MB. debug:node:Buffer (94633599 bytes) debug:node:base64Buffer (126178132 bytes)

This thread is trying to answer question "What is the maximum size of a string parameter that can be passed to the `page.evaluate(fn,stringArg)` function?"

1 reply

Answering my own question:

The maximum length of a string parameter to page.evaluate(fn,stringArg) is 100MiB

Test repo: https://github.com/daneroo/playwright-max-payload

Hello Playwright payload maximizing tester!
roundTripSize Success: 104852480 == 104852480 bytes 99.9951 == 99.9951 MiB
roundTripSize Success: 104853504 == 104853504 bytes 99.9961 == 99.9961 MiB
roundTripSize Success: 104854528 == 104854528 bytes 99.9971 == 99.9971 MiB
roundTripSize Success: 104855552 == 104855552 bytes 99.9980 == 99.9980 MiB
roundTripSize Success: 104856576 == 104856576 bytes 99.9990 == 99.9990 MiB
roundTripSize Failure: 104857600 bytes 100 MiB
Error: page.evaluate: Target closed

Related Discord Threads

TwitterGitHubLinkedIn
AboutQuestionsDiscord ForumBrowser ExtensionTagsQA Jobs

Rayrun is a community for QA engineers. I am constantly looking for new ways to add value to people learning Playwright and other browser automation frameworks. If you have feedback, email luc@ray.run.