Skip to content

fix(runner): wire --timeout, default output dir, reliable artifacts#1377

Merged
Mateus Zitelli (MateusZitelli) merged 12 commits into
mainfrom
replay-fixes-into-cli
Jun 17, 2026
Merged

fix(runner): wire --timeout, default output dir, reliable artifacts#1377
Mateus Zitelli (MateusZitelli) merged 12 commits into
mainfrom
replay-fixes-into-cli

Conversation

@michael-pr

Copy link
Copy Markdown
Contributor

Description drafted with AI, edited and reviewed by me.

Relates to cli-private #175, #176, #177, #178

Overview of Changes

Replays four reviewed and merged internal PRs (#175–#178) into the public @qawolf/cli repository, preserving smonn's (Simon Ingeson) original authorship across all 12 commits. The changes close three gaps: --timeout was silently dropped before reaching the Playwright expect call inside web flows; the default run output directory was not gitignored, risking accidental artifact commits; and HAR/trace artifacts were lost on early exits because browsers were closed before their contexts, with flush order also not preserved during signal shutdown.

Testing

All three fixes ship with colocated tests added in the same commits (runWebFlow.trace.test.ts, contextSetup.trace.test.ts, paths.test.ts, and updates to runWebFlow.test.ts). These commits are a verbatim replay of PRs already tested and merged in the internal repository — no additional manual verification steps are required beyond CI.

Checklist

  • Changes follow the code style of this project
  • Self-review completed
  • Tests added/updated (or not applicable)
  • No breaking changes (or described below)

--timeout set the Playwright context default action timeout but not the
@qawolf/flows expect-wrapper timeout, which stayed pinned at its hardcoded
30s default. Assertion failures (the common case) ignored the flag.

Thread the timeout through initFlowRuntime into configureFlowRuntime as
webExpectAttributes.defaultExpectTimeoutMs, and reword the flag help to
reflect its per-action/assertion semantics.

Non-web flows remain unwired (WIZ-10830).

Fixes WIZ-10821
The readback test observes a process-global on @qawolf/flows and
initFlowRuntime memoizes per flow directory. Sibling runner tests share
that directory, so a prior cache entry could skip the reconfigure and
leave a stale timeout — failing only under cross-file test ordering in
CI. Reset the cache before the assertion to force a fresh configure.
Clears the @qawolf/flows expect-timeout config the readback test sets, so
it cannot leak into later tests in this file (CodeRabbit nitpick).
Close contexts fully before browsers in createLaunch cleanup. Playwright
flushes HAR/video/trace during context.close(), and the previous
concurrent browser.close() could terminate the connection mid-flush,
silently dropping artifacts (reproduced as flaky HAR loss).

Wire trace recording through the runner: the parsed --trace flag was
dropped in buildRunOptions, omitted from RunWebFlowOptions, and
tracing.start/stop was never called. Add traceFlowPath/initTrace/
maybeCleanupTrace symmetric to HAR, start tracing after context
creation, and stop to the trace path during cleanup. Respect
on/off/retain-on-failure.

Fixes WIZ-10823
Correct the cleanup comment: context.close() flushes HAR/video, while
the trace zip is written by the preceding tracing.stop(). Note that a
SIGINT-interrupted run preserves HAR/video but not the trace, since the
signal handlers only close the context.

Add a TODO WIZ-10839 for the multi-launch last-wins artifact path:
multiple launch() calls in one flow stop every context to the same
trace path, so only one zip survives (mirrors existing HAR behavior).

Surfaced during adversarial review of WIZ-10823.
createLaunch registered context.close() and browser.close() as separate
signal cleanups, but SignalRegistry runs cleanups concurrently — so a
SIGINT could race browser.close() against the context's HAR/video flush,
the same way the old concurrent cleanup did. Register a single ordered
teardown (stop tracing, close contexts, then browsers) used by both
normal cleanup and signal shutdown, guarded against double-run.

Surfaced by CodeRabbit on PR #178.
When a passing flow's HAR/trace file cannot be deleted under
retain-on-failure, the error was swallowed silently, leaving a stale
artifact the user never heard about. Log a warning with the path via the
runner logger so it can be removed manually. Cleanup failure still never
fails a passing flow.

Addresses review feedback from @michael-pr on PR #178.
@coderabbitai

coderabbitai Bot commented Jun 17, 2026

Copy link
Copy Markdown

Review Change Stack

Note

Reviews paused

Use the following commands to manage reviews:

  • @coderabbitai resume to resume automatic reviews.
  • @coderabbitai review to trigger a single review.

Use the checkboxes below for quick actions:

  • ▶️ Resume reviews
  • 🔍 Trigger review

Walkthrough

Three coordinated patches are applied to @qawolf/cli. First, qawolfDir (.qawolf) and defaultOutputDir (.qawolf/output) constants are introduced in src/core/paths.ts and consumed in the config schema, init template, and CLI --output-dir flag default, replacing hardcoded strings. Second, initFlowRuntime gains a required options.timeout parameter that is threaded into configureFlowRuntime as webExpectAttributes.defaultExpectTimeoutMs, making --timeout apply to both actions and assertions. Third, full Playwright trace support is wired: contextSetup.ts gains traceFlowPath, initTrace, and maybeCleanupTrace; createLaunch is reworked to use a single ordered closeAll teardown (stop tracing → close contexts → close browsers) to prevent silent artifact drops; and runWebFlow calls initTrace and passes traceMode/tracePath into createLaunch.

Estimated code review effort

🎯 4 (Complex) | ⏱️ ~60 minutes

🚥 Pre-merge checks | ✅ 4
✅ Passed checks (4 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly summarizes the three main changes in imperative mood, is concise at 67 characters, and follows the expected format without unnecessary prefix or punctuation.
Description check ✅ Passed The description provides a clear overview of changes, explains the rationale for each fix, confirms tests were added, and includes a completed checklist matching the template structure.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.


Comment @coderabbitai help to get the list of available commands and usage tips.

@michael-pr

Copy link
Copy Markdown
Contributor Author

CodeRabbit (@coderabbitai) review

@coderabbitai

coderabbitai Bot commented Jun 17, 2026

Copy link
Copy Markdown
✅ Action performed

Review finished.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

@michael-pr

Copy link
Copy Markdown
Contributor Author

CodeRabbit (@coderabbitai) pause

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@src/domains/runner/runWebFlowUtils.ts`:
- Around line 59-69: The `closeAll` function uses a `closed` boolean flag to
prevent re-entry but does not expose the in-flight teardown promise, causing
concurrent callers to return early without waiting for cleanup to complete. To
fix this, declare a persistent variable outside the function to store the
pending teardown promise, then modify `closeAll` to check if a teardown is
already in progress and return that existing promise instead of returning
immediately. When initiating a new teardown, assign the entire promise chain
containing the tracing stop and context/browser closures to that variable before
awaiting it, ensuring all concurrent callers properly wait for the same teardown
operation to complete.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: ASSERTIVE

Plan: Pro Plus

Run ID: eca08d45-8f16-47b3-97b6-bb1b7f390207

📥 Commits

Reviewing files that changed from the base of the PR and between 3af2ffc and ee03192.

⛔ Files ignored due to path filters (1)
  • src/commands/__snapshots__/help.test.ts.snap is excluded by !**/*.snap
📒 Files selected for processing (26)
  • .changeset/gitignored-default-output-dir.md
  • .changeset/har-trace-artifacts.md
  • .changeset/timeout-web-flow-expect.md
  • src/commands/flows/run.register.ts
  • src/core/messages/runner.ts
  • src/core/paths.test.ts
  • src/core/paths.ts
  • src/domains/config/loadConfig.test.ts
  • src/domains/config/schema.ts
  • src/domains/init/templates.ts
  • src/domains/runner/dispatchViaSubprocess.test.ts
  • src/domains/runner/executeWorkerFlow.test.ts
  • src/domains/runner/initFlowRuntime.test.ts
  • src/domains/runner/initFlowRuntime.ts
  • src/domains/runner/run.manifestStamp.test.ts
  • src/domains/runner/runHelpers.test.ts
  • src/domains/runner/runHelpers.ts
  • src/domains/runner/runWebFlow.fixtures.ts
  • src/domains/runner/runWebFlow.test.ts
  • src/domains/runner/runWebFlow.trace.test.ts
  • src/domains/runner/runWebFlow.ts
  • src/domains/runner/runWebFlowUtils.test.ts
  • src/domains/runner/runWebFlowUtils.ts
  • src/domains/runner/web/contextSetup.test.ts
  • src/domains/runner/web/contextSetup.trace.test.ts
  • src/domains/runner/web/contextSetup.ts

Comment thread src/domains/runner/runWebFlowUtils.ts
@coderabbitai

coderabbitai Bot commented Jun 17, 2026

Copy link
Copy Markdown
✅ Action performed

Reviews paused.

@MateusZitelli Mateus Zitelli (MateusZitelli) merged commit 9c3db03 into main Jun 17, 2026
2 checks passed
@MateusZitelli Mateus Zitelli (MateusZitelli) deleted the replay-fixes-into-cli branch June 17, 2026 08:26
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

3 participants