Skip to content

[🐛 Bug]: Repeated execute / executeAsync can leak large amounts of memory #13209

@johnp

Description

@johnp

Have you read the Contributing Guidelines on issues?

WebdriverIO Version

8.39.1

Node.js Version

20.15.1

Mode

Standalone Mode

Which capabilities are you using?

No response

What happened?

We noticed OOM errors in our CI runners after introducing rigorous a11y tests using @axe-core/webdriverio (rigorous meaning: running Axe whenever the UI changes). In dequelabs/axe-core-npm#1086 I've traced this down to this happening:

  1. On every AxeBuilder::analyze call, @axe-core/webdriverio uses execute / executeAsync to execute (rather large) script(s). (the main axe-core script is 1.2 MiB)
  2. WebdriverIO internally executes a protocol command, which emits, among other data, the "body" (script) here.
  3. That object is then emitted to the configured reporters here.
  4. And persisted in the TestStats here.

(note the links are all to recent commits on main (v9), but IIRC code flow is essentially identical in v8)

What is your expected behavior?

I don't know why every single execute / executeAsync script execution needs to be persisted in the "TestStats". If that is not necessary, it should be removed. Alternatively, we could:

  • Provide an option for execute and executeAsync to opt out of this behavior, or
  • Only persist the first X bytes of the script (maybe 1KB?), to reduce the impact, or
  • Somehow make sure that duplicate scripts in the TestStats all refer to the same in-memory string,
  • ... ?

Happy to hear any other options/ideas. In the mean time, if there's a anything which let's us clean up these TestStats during the run, so that our CI doesn't OOM, I would appreciate any pointers.

How to reproduce the bug.

Follow the instructions in https://github.com/johannespfrang/axe-wdio-memory-leak.

Relevant log output

Nothing relevant.

Code of Conduct

  • I agree to follow this project's Code of Conduct

Is there an existing issue for this?

  • I have searched the existing issues

Metadata

Metadata

Assignees

No one assigned

    Labels

    Bug 🐛help wantedIssues that are free to take by anyone interested

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions