Skip to content

fix(test): stop cy.log in the Cypress fail listener masking real errors - #42112

Open
wyattwalter wants to merge 1 commit into
releasefrom
ww-flake/fail-handler-cylog
Open

fix(test): stop cy.log in the Cypress fail listener masking real errors#42112
wyattwalter wants to merge 1 commit into
releasefrom
ww-flake/fail-handler-cylog

Conversation

@wyattwalter

@wyattwalter wyattwalter commented Aug 11, 2026

Copy link
Copy Markdown
Contributor

Description

app/client/cypress/support/e2e.js registers a Cypress.on("fail") listener that calls cy.log(error.message).

Event listeners run outside the Cypress command queue, so enqueuing a cy.* command there makes Cypress raise a second error:

CypressError: Cypress detected that you returned a promise from a command
while also invoking one or more cy commands in that promise.
  The command that returned the promise was:   > `cy.reload()`
  The cy command you invoked inside the promise was:   > `cy.log()`

That second error is what lands in the job log and the mochawesome report, so the real assertion failure is replaced by a message about promises. This is the same bug class as #42069 (cy.log inside a cy.intercept response handler); that PR fixed the intercept instance and this is the remaining one — the completeness check missed it because the call site is an event listener rather than an intercept handler.

The fix logs outside the command queue and keeps the rethrow, matching the pattern #42069 established.

This does not make any failing spec pass. It stops failing specs from being misreported, which is what makes them hard to triage.

Evidence

Mined from the 12 most recent test-build-docker-image.yml scheduled runs on appsmithorg/appsmith-ee, 2026-08-06 through 2026-08-11 (all post-#42069, so the intercept instance is already fixed):

  • 8 occurrences across 7 of 12 runs, in 5 distinct specs:
    EE/Enterprise/MultipleEnv/ME_CustomEnv_spec.ts,
    EE/Enterprise/SettingsPane/BrandingBuisness_Settings_spec.ts,
    EE/Enterprise/AuditLogs/Audit_logs_EEAccess_spec.js,
    EE/Enterprise/RBAC/RBACUITests/Users_spec.js,
    Regression/ClientSide/Widgets/Input/InputRTL_support.ts.
  • The stack identifies the emitter path rather than an intercept:
at cy.<computed> [as log] (cypress_runner.js)
at listener (cypress_runner.js:140042)
at $Cypress.<anonymous> (cypress_runner.js:140044)
at parent.<computed> [as emitMap]
at $Cypress.action
  • Worked example, run 31376991838 shard 28, BrandingBuisness_Settings_spec.ts: the real failure is a toast assertion (AggregateHelper.ValidateToastMessage -> GetNAssertContains -> GetElement). What the report shows instead is the promise CypressError.
  • When the masked failure happens in a before all hook, the log reads Because this error occurred during a 'before all' hook we are skipping the remaining tests in the current suite, attributing a whole skipped suite to the promise error rather than to the assertion that actually failed (run 31462702539 shard 2, ME_CustomEnv_spec.ts).

Completeness check: a brace-scan of every Cypress.on(...) block across app/client/cypress finds exactly one cy.* call in each repo — this one. The same scan was validated against the pre-#42069 tree, where it correctly reports FeatureFlags.ts:75.

Type of change

  • Bug fix (non-breaking change which fixes an issue)

Automation

/ok-to-test tags="@tag.All"

Related

https://linear.app/appsmith/issue/APP-15705

Tip

🟢 🟢 🟢 All cypress tests have passed! 🎉 🎉 🎉
Workflow run: https://github.com/appsmithorg/appsmith/actions/runs/31490627773
Commit: caa5d6c
Cypress dashboard.
Tags: @tag.All
Spec:


Tue, 11 Aug 2026 13:27:19 UTC

Summary by CodeRabbit

  • Bug Fixes
    • Improved Cypress error reporting to avoid command-queue conflicts while preserving failure details.

Cypress.on("fail") runs outside the Cypress command queue. Calling cy.log
there raises a second CypressError ("returned a promise from a command while
also invoking one or more cy commands"), which replaces the original failure
in the job log and the mochawesome report.

Log outside the queue instead, and keep the rethrow.
@wyattwalter wyattwalter added the ok-to-test Required label for CI label Aug 11, 2026
@coderabbitai

coderabbitai Bot commented Aug 11, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: aef3b386-acd0-40e1-ac88-1b507f536e3b

📥 Commits

Reviewing files that changed from the base of the PR and between 107634b and caa5d6c.

📒 Files selected for processing (1)
  • app/client/cypress/support/e2e.js

Walkthrough

The Cypress failure handler now uses synchronous console.log logging instead of queued cy.log logging. It continues to rethrow the original error.

Changes

Cypress failure handling

Layer / File(s) Summary
Failure logging and propagation
app/client/cypress/support/e2e.js
The Cypress.on("fail") handler logs error.message with console.log and rethrows the failure.

Estimated code review effort: 1 (Trivial) | ~3 minutes

Suggested reviewers: amelia-c0n, sebastianiv21, sondermanish, subrata71, tomjose92

Poem

A failure speaks in the console light,
No queued command disrupts the night.
The error rises, clear and true,
Then Cypress carries on its due.

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly identifies the Cypress fix and explains that cy.log no longer masks real errors.
Description check ✅ Passed The description explains the problem, motivation, fix, evidence, issue reference, automation, test results, and change type; only Communication is missing.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
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.
✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch ww-flake/fail-handler-cylog

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

@wyattwalter
wyattwalter marked this pull request as ready for review August 11, 2026 13:28
@wyattwalter
wyattwalter requested a review from a team as a code owner August 11, 2026 13:28
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

ok-to-test Required label for CI

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant