Skip to content

Conversation

@conte91
Copy link

@conte91 conte91 commented Jul 4, 2025

Fixes #57 and duplicates without the need for downgrading the playwright version.

Playwright's init scripts are not executed sequentially, as per PW's docs:

image

However, some benchmarks depend on all installed init scripts to be executed in order, which is why the page hangs if they don't (in WorkArena's case, this was because of the function being waited on being undefined - since the script defining it hadn't been evaluated yet).

It shouldn't cause any problem to just concatenate all scripts together, so that we can guarantee FIFO execution order.

@conte91 conte91 marked this pull request as draft July 4, 2025 17:20
Comment on lines 155 to 157
page.evaluate(init_script_js)
for f in page.frames:
f.evaluate(init_script_js)
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think the evaluate lines should be removed

@conte91 conte91 requested a review from younik July 11, 2025 11:09
@conte91 conte91 changed the title Workarena/Base: Add init scripts a single JS file in all page/frames. Workarena/Base: Merge init scripts before evaluation. Jul 16, 2025
@conte91 conte91 marked this pull request as ready for review July 16, 2025 18:31
@conte91
Copy link
Author

conte91 commented Jul 16, 2025

Self-note: this could be an issue in case names defined across scripts shadow each other?

Something like:

add_init_script(`const Math = () => {alert("fake math!");}`)
add_init_script(`Math.random()`)

I think we should be fine though, because even if two scripts' private functions will share the same name, the last one defined will win.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug]: Hitting Timeouts error almost systematically

2 participants