Skip to content

fix(run-workers): keep metaStep and readable args in main-process steps (#5820) - #5821

Open
mirao wants to merge 2 commits into
codeceptjs:4.xfrom
mirao:fix/run-workers-step-metastep-5820
Open

mirao wants to merge 2 commits into
codeceptjs:4.xfrom
mirao:fix/run-workers-step-metastep-5820

Conversation

@mirao

@mirao mirao commented Nov 27, 2026

Copy link
Copy Markdown
Contributor

Fixes #5820

Problem

Under run-workers, steps reach main-process listeners as plain objects produced by Step.simplify() and rebuilt by deserializeStep() / deserializeTest(). simplify() dropped metaStep and JSON-serialized object arguments, so reporters saw steps inside within(), page objects and Section as flat, and locators as raw JSON such as I click "{"type":"xpath",...}". Secrets were also sent unmasked, e.g. {"_secret":"123"}. run and run-multiple are not affected, because their reporters run in the same process as the tests and get the real Step objects.

Changes

  • lib/step/base.js: simplify() now sends:
    • the meta step chain,
    • humanizedArgs, so toString() in the main process matches the worker,
    • toString() for arguments that have their own, such as Locator,
    • masked Secret values, also one level deep inside plain objects.
  • lib/step/meta.js: MetaStep.simplify() adds a unique id, actor, collapsed and its toString() text. The text is needed for subclasses such as within()'s step, which print themselves differently.
  • lib/step/deserialize.js (new): a shared deserializeStep(), used by lib/workers.js and deserializeTest(). It rebuilds MetaStep instances, and steps that shared one meta step in the worker share one instance again, so reporters can group by object identity. The cache holds only weak references, so it doesn't grow during a run.
  • test/unit/step/deserialize_test.js: 7 new tests.

Tests

  • The repro from the issue, extended with a page object, Section and secret(): under run-workers, main-process steps now print the same as under run.
  • npx mocha test/unit --recursive: 979 passing.
  • npx mocha test/runner/run_workers_test.js: 43 passing.
  • Playwright acceptance run-workers 2 --grep within: 12 passed, 1 skipped.

🤖 Generated with Claude Code

mirao and others added 2 commits November 27, 2026 13:42
…ps (codeceptjs#5820)

Step.simplify() dropped the metaStep chain and JSON-serialized object
arguments, so reporters in the main process saw within()/page object/
Section steps flat and locators as raw JSON (and secrets unmasked).

simplify() now sends the meta step chain and humanized args; a shared
deserializeStep() rebuilds MetaStep instances, sharing one instance per
worker meta step so reporters can group by identity.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@mirao

mirao commented Nov 27, 2026

Copy link
Copy Markdown
Contributor Author

The two failing checks also fail without this PR:

Created by AI agent (Claude Code)

This branch has not been deployed

No deployments
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.

run-workers: Step.simplify() drops metaStep and JSON-serializes locators, so main-process reporters lose within()/section nesting

1 participant