Skip to content

test: fix flaky timeout in channel-management beforeEach navigation - #41385

Closed
KevLehman wants to merge 4 commits into
developfrom
claude/channel-management-test-timeout-pgg12h
Closed

test: fix flaky timeout in channel-management beforeEach navigation#41385
KevLehman wants to merge 4 commits into
developfrom
claude/channel-management-test-timeout-pgg12h

Conversation

@KevLehman

@KevLehman KevLehman commented Jul 15, 2026

Copy link
Copy Markdown
Member

Proposed changes (including videos or screenshots)

Fixes a flaky timeout in channel-management.spec.ts where the suite's shared beforeEach hook could consume the entire 60s test timeout before the test body ever started, e.g. in this run:

tests/e2e/channel-management.spec.ts:292:7 › channel-management › cross user tests › should unignore user1 messages
Test timeout of 60000ms exceeded while running "beforeEach" hook.

Diagnosis (from the CI logs):

  • All 18 prior tests in the serial suite passed in 6–15s each, and the server logs show it idle during the hang — the server was healthy.
  • The hook does page.goto('/home') and then waits for the "Home" heading. The timing shows goto spent nearly its full 30s navigation budget waiting for the page load event, and the heading then never appeared in the remaining ~28s — the test timeout killed the wait while it was still pending (hence the Target page, context or browser has been closed error).

This matches the failure mode already documented in #41319 (preview-public-channel flake): on a busy CI runner the client boot is slow or gets stuck on the loading screen, and no amount of waiting recovers it — only a fresh navigation does.

Changes:

  • Wrap the navigation in expect(async () => { ... }).toPass() — Playwright's built-in retry mechanism, already used elsewhere in the e2e suite — so a stuck boot triggers a fresh goto attempt instead of a single wait exhausting the whole test timeout.
  • Navigate with waitUntil: 'domcontentloaded' (same pattern used in sidebar-menu.spec.ts), so each attempt doesn't spend its budget waiting for full asset loading — what actually matters is the Home heading, which is waited on explicitly with a bounded 15s timeout per attempt.
  • HomeChannel.waitForHome() now accepts an optional timeout param (backward-compatible for all other callers).

No changeset needed — test-only change.

Issue(s)

Steps to test or reproduce

The failure is CI-load dependent and not deterministically reproducible locally. Run the suite to verify no regression:

yarn playwright test tests/e2e/channel-management.spec.ts

The suite still passes on the happy path (the retry only kicks in when the Home page fails to render within the bounded wait).

Further comments

Alternatives considered: raising the per-test timeout would hide genuine slow-downs and still fail when the boot is truly stuck; moving goto out of beforeEach (the #41319 approach) doesn't map here since there are no per-test API mutations racing the boot — every test needs the same fresh navigation; a try/catch with a manual page.reload() fallback works but hand-rolls what toPass() already expresses declaratively.

🤖 Generated with Claude Code

https://claude.ai/code/session_01GYTXKLTT79eSBmX2sz1WeE

Summary by CodeRabbit

  • Tests
    • Improved channel management e2e reliability with retryable, time-bound setup steps and a more deterministic home-page load condition.
    • Enhanced home-page readiness checks by adding an optional timeout parameter, including a bounded wait during CI to reduce intermittent loading-screen hangs.

The beforeEach hook navigates to /home before every test and could burn
the entire 60s test timeout when the CI runner is slow: page.goto waits
for the 'load' event (observed taking ~30s), and the client boot can get
stuck on the loading screen, leaving the Home heading invisible until
the test times out (as seen in 'should unignore user1 messages').

Navigate with waitUntil: 'domcontentloaded' so the hook waits on the
Home heading instead of full asset loading, bound the first wait to 15s,
and recover from a stuck boot with a single reload before waiting again.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01GYTXKLTT79eSBmX2sz1WeE
@dionisio-bot

dionisio-bot Bot commented Jul 15, 2026

Copy link
Copy Markdown
Contributor

Looks like this PR is not ready to merge, because of the following issues:

  • This PR is missing the 'stat: QA assured' label

Please fix the issues and try again

If you have any trouble, please check the PR guidelines

@changeset-bot

changeset-bot Bot commented Jul 15, 2026

Copy link
Copy Markdown

⚠️ No Changeset found

Latest commit: 8f1f118

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

This PR includes no changesets

When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

Click here to learn what changesets are, and how to add one.

Click here if you're a maintainer who wants to add a changeset to this PR

@coderabbitai

coderabbitai Bot commented Jul 15, 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: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: bd3b240d-ab71-41aa-a8f3-c97053b97e27

📥 Commits

Reviewing files that changed from the base of the PR and between 3e5ce66 and 8f1f118.

📒 Files selected for processing (1)
  • apps/meteor/tests/e2e/channel-management.spec.ts
🚧 Files skipped from review as they are similar to previous changes (1)
  • apps/meteor/tests/e2e/channel-management.spec.ts
📜 Recent review details
⏰ Context from checks skipped due to timeout. (3)
  • GitHub Check: CodeQL-Build
  • GitHub Check: Hacktron Security Check
  • GitHub Check: CodeQL-Build

Walkthrough

The e2e home setup now retries /home navigation with bounded waits, and waitForHome accepts an optional timeout forwarded to Playwright.

Changes

Home navigation reliability

Layer / File(s) Summary
Bounded home navigation setup
apps/meteor/tests/e2e/channel-management.spec.ts, apps/meteor/tests/e2e/page-objects/home-channel.ts
The setup uses DOM content navigation and retries home readiness with a 15-second visibility timeout; waitForHome forwards optional timeout values to Playwright.

Estimated code review effort: 2 (Simple) | ~10 minutes

Possibly related PRs

Suggested labels: type: chore

Suggested reviewers: cardoso, julia jforesti

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title accurately summarizes the main change: fixing a flaky timeout in channel-management beforeEach navigation.
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.

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

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

@CLAassistant

CLAassistant commented Jul 15, 2026

Copy link
Copy Markdown

CLA assistant check
All committers have signed the CLA.

@codecov

codecov Bot commented Jul 15, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 68.29%. Comparing base (0faaaeb) to head (8f1f118).
⚠️ Report is 66 commits behind head on develop.

Additional details and impacted files

Impacted file tree graph

@@             Coverage Diff             @@
##           develop   #41385      +/-   ##
===========================================
+ Coverage    68.21%   68.29%   +0.07%     
===========================================
  Files         3968     3968              
  Lines       154740   154771      +31     
  Branches     27825    27802      -23     
===========================================
+ Hits        105557   105694     +137     
+ Misses       44392    44279     -113     
- Partials      4791     4798       +7     
Flag Coverage Δ
e2e 59.22% <ø> (-0.02%) ⬇️
e2e-api 44.33% <ø> (+0.27%) ⬆️
unit 70.40% <ø> (-0.25%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@KevLehman
KevLehman marked this pull request as ready for review July 15, 2026 06:49
@KevLehman
KevLehman requested a review from a team as a code owner July 15, 2026 06:49

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

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 `@apps/meteor/tests/e2e/channel-management.spec.ts`:
- Around line 24-27: Remove the explanatory comment immediately before the
expect retry block in the channel-management test, leaving the retry
implementation unchanged.
🪄 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: CHILL

Plan: Pro

Run ID: b2f62762-be3a-49e2-b54b-e1daa2fefb1a

📥 Commits

Reviewing files that changed from the base of the PR and between 4b34bd6 and 914ca1f.

📒 Files selected for processing (2)
  • apps/meteor/tests/e2e/channel-management.spec.ts
  • apps/meteor/tests/e2e/page-objects/home-channel.ts
📜 Review details
⏰ Context from checks skipped due to timeout. (2)
  • GitHub Check: cubic · AI code reviewer
  • GitHub Check: Hacktron Security Check
🧰 Additional context used
📓 Path-based instructions (5)
**/*.{ts,tsx,js}

📄 CodeRabbit inference engine (.cursor/rules/playwright.mdc)

**/*.{ts,tsx,js}: Write concise, technical TypeScript/JavaScript with accurate typing in Playwright tests
Avoid code comments in the implementation

Files:

  • apps/meteor/tests/e2e/page-objects/home-channel.ts
  • apps/meteor/tests/e2e/channel-management.spec.ts
apps/meteor/tests/e2e/page-objects/**/*.ts

📄 CodeRabbit inference engine (.cursor/rules/playwright.mdc)

Utilize existing page objects pattern from apps/meteor/tests/e2e/page-objects/

Files:

  • apps/meteor/tests/e2e/page-objects/home-channel.ts
apps/meteor/tests/e2e/**/*.{ts,spec.ts}

📄 CodeRabbit inference engine (.cursor/rules/playwright.mdc)

apps/meteor/tests/e2e/**/*.{ts,spec.ts}: Store commonly used locators in variables/constants for reuse
Follow Page Object Model pattern consistently in Playwright tests

Files:

  • apps/meteor/tests/e2e/page-objects/home-channel.ts
  • apps/meteor/tests/e2e/channel-management.spec.ts
**/*.spec.ts

📄 CodeRabbit inference engine (.cursor/rules/playwright.mdc)

**/*.spec.ts: Use descriptive test names that clearly communicate expected behavior in Playwright tests
Use .spec.ts extension for test files (e.g., login.spec.ts)

Files:

  • apps/meteor/tests/e2e/channel-management.spec.ts
apps/meteor/tests/e2e/**/*.spec.ts

📄 CodeRabbit inference engine (.cursor/rules/playwright.mdc)

apps/meteor/tests/e2e/**/*.spec.ts: All test files must be created in apps/meteor/tests/e2e/ directory
Avoid using page.locator() in Playwright tests - always prefer semantic locators such as page.getByRole(), page.getByLabel(), page.getByText(), or page.getByTitle()
Use test.beforeAll() and test.afterAll() for setup/teardown in Playwright tests
Use test.step() for complex test scenarios to improve organization in Playwright tests
Group related tests in the same file
Utilize Playwright fixtures (test, page, expect) for consistency in test files
Prefer web-first assertions (toBeVisible, toHaveText, etc.) in Playwright tests
Use expect matchers for assertions (toEqual, toContain, toBeTruthy, toHaveLength, etc.) instead of assert statements in Playwright tests
Use page.waitFor() with specific conditions instead of hardcoded timeouts in Playwright tests
Implement proper wait strategies for dynamic content in Playwright tests
Maintain test isolation between test cases in Playwright tests
Ensure clean state for each test execution in Playwright tests
Ensure tests run reliably in parallel without shared state conflicts

Files:

  • apps/meteor/tests/e2e/channel-management.spec.ts
🧠 Learnings (7)
📚 Learning: 2025-12-16T17:29:40.430Z
Learnt from: gabriellsh
Repo: RocketChat/Rocket.Chat PR: 37834
File: apps/meteor/tests/e2e/page-objects/fragments/admin-flextab-emoji.ts:12-22
Timestamp: 2025-12-16T17:29:40.430Z
Learning: In all page-object files under apps/meteor/tests/e2e/page-objects/, import expect from ../../utils/test (Playwright's async expect) instead of from Jest. Jest's expect is synchronous and incompatible with web-first assertions like toBeVisible, which can cause TypeScript errors.

Applied to files:

  • apps/meteor/tests/e2e/page-objects/home-channel.ts
📚 Learning: 2026-02-24T19:39:42.247Z
Learnt from: juliajforesti
Repo: RocketChat/Rocket.Chat PR: 38493
File: apps/meteor/tests/e2e/page-objects/fragments/message.ts:7-7
Timestamp: 2026-02-24T19:39:42.247Z
Learning: In RocketChat e2e tests, avoid using data-qa attributes to locate elements. Prefer semantic locators such as getByRole, getByLabel, getByText, getByTitle and ARIA-based selectors. Apply this rule to all TypeScript files under apps/meteor/tests/e2e to improve test reliability, accessibility, and maintainability.

Applied to files:

  • apps/meteor/tests/e2e/page-objects/home-channel.ts
  • apps/meteor/tests/e2e/channel-management.spec.ts
📚 Learning: 2026-02-26T19:25:44.063Z
Learnt from: gabriellsh
Repo: RocketChat/Rocket.Chat PR: 38778
File: packages/ui-voip/src/providers/useMediaSession.ts:192-192
Timestamp: 2026-02-26T19:25:44.063Z
Learning: In the Rocket.Chat repository, do not reference Biome lint rules in code review feedback. Biome is not used even if biome.json exists; only reference Biome rules if there is explicit, project-wide usage documented. For TypeScript files, review lint implications without Biome guidance unless the project enables Biome rules.

Applied to files:

  • apps/meteor/tests/e2e/page-objects/home-channel.ts
  • apps/meteor/tests/e2e/channel-management.spec.ts
📚 Learning: 2026-02-26T19:25:44.063Z
Learnt from: gabriellsh
Repo: RocketChat/Rocket.Chat PR: 38778
File: packages/ui-voip/src/providers/useMediaSession.ts:192-192
Timestamp: 2026-02-26T19:25:44.063Z
Learning: In this repository (RocketChat/Rocket.Chat), Biome lint rules are not used even if a biome.json exists. When reviewing TypeScript files (e.g., packages/ui-voip/src/providers/useMediaSession.ts), ensure lint suggestions do not reference Biome-specific rules. Rely on general ESLint/TypeScript lint rules and project conventions instead.

Applied to files:

  • apps/meteor/tests/e2e/page-objects/home-channel.ts
  • apps/meteor/tests/e2e/channel-management.spec.ts
📚 Learning: 2026-05-06T12:21:44.083Z
Learnt from: juliajforesti
Repo: RocketChat/Rocket.Chat PR: 40256
File: apps/meteor/client/components/CreateDiscussion/CreateDiscussion.tsx:121-149
Timestamp: 2026-05-06T12:21:44.083Z
Learning: Field wrappers in rocket.chat/fuselage-forms (Field, FieldLabel, FieldRow, FieldError, FieldHint) auto-create htmlFor/id associations, aria-describedby, and role="alert" for errors. Do not manually set htmlFor, id, aria-describedby, or role attributes when using these wrappers. This automatic wiring does not apply to plain rocket.chat/fuselage components, which require explicit ID wiring per the accessibility docs. In code reviews, prefer using fuselage-forms wrappers for form fields and verify there is no unnecessary manual ID/aria wiring in files that use these wrappers. If a component uses plain fuselage components, ensure proper id wiring as per docs.

Applied to files:

  • apps/meteor/tests/e2e/page-objects/home-channel.ts
  • apps/meteor/tests/e2e/channel-management.spec.ts
📚 Learning: 2026-02-24T19:22:48.358Z
Learnt from: juliajforesti
Repo: RocketChat/Rocket.Chat PR: 38493
File: apps/meteor/tests/e2e/omnichannel/omnichannel-send-pdf-transcript.spec.ts:66-67
Timestamp: 2026-02-24T19:22:48.358Z
Learning: In Playwright end-to-end tests (e.g., under apps/meteor/tests/e2e/...), prefer locating elements by translated text (getByText) and ARIA roles (getByRole) over data-qa attributes. If translation values change, update the corresponding test locators accordingly. Never use data-qa locators. This guideline applies to all Playwright e2e test specs in the repository and helps keep tests robust to UI text changes and accessible semantics.

Applied to files:

  • apps/meteor/tests/e2e/channel-management.spec.ts
📚 Learning: 2026-03-06T18:10:15.268Z
Learnt from: tassoevan
Repo: RocketChat/Rocket.Chat PR: 39397
File: packages/gazzodown/src/code/CodeBlock.spec.tsx:47-68
Timestamp: 2026-03-06T18:10:15.268Z
Learning: In tests (especially those using testing-library/dom/jsdom) for Rocket.Chat components, the HTML <code> element has an implicit ARIA role of 'code'. Therefore, screen.getByRole('code') or screen.findByRole('code') will locate <code> elements even without a role attribute. Do not flag findByRole('code') as invalid in reviews; prefer using the implicit role instead of adding role="code" unless necessary for accessibility.

Applied to files:

  • apps/meteor/tests/e2e/channel-management.spec.ts
🔇 Additional comments (1)
apps/meteor/tests/e2e/page-objects/home-channel.ts (1)

191-192: LGTM!

Comment thread apps/meteor/tests/e2e/channel-management.spec.ts Outdated

@cubic-dev-ai cubic-dev-ai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

All reported issues were addressed across 2 files

Reply with feedback, questions, or to request a fix.

Re-trigger cubic

Comment thread apps/meteor/tests/e2e/channel-management.spec.ts
claude added 2 commits July 15, 2026 07:00
An unbounded toPass() retries until the overall test timeout, which
reproduces the opaque 'timeout exceeded in beforeEach' failure when the
client boot is stuck for good. A 30s budget still allows two full
navigation attempts and fails with a clear toPass timeout error instead.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01GYTXKLTT79eSBmX2sz1WeE
@dougfabris

dougfabris commented Jul 15, 2026

Copy link
Copy Markdown
Member

I suppose that something really wrong was happening during this run, and I quite don't agree with this approach. If we're assuming our app can take this amount of time and we're going to wait and add a timeout for every single time such situation happens, we're going to have the most delayed continuous integration over and over again

Copy link
Copy Markdown
Member Author

Agreed that something was genuinely wrong in that run — the server logs show it healthy and idle while the client sat on the loading screen for 55+ seconds, so this looks like the client boot occasionally hanging (same failure mode #41319 hit in preview-public-channel). That root cause deserves its own investigation, and this PR intentionally doesn't try to hide it: if the boot is truly stuck, the hook still fails — just at a bounded 30s with a clear toPass timeout error, instead of silently burning the full 60s test budget.

On CI speed, this change actually goes the other direction:

  • Happy path adds zero waiting. The toPass block only retries when the Home heading fails to appear within 15s — in every green run since, it never looped once.
  • The suite got faster, not slower. Navigating with waitUntil: 'domcontentloaded' instead of the default full load event cut the cross-user tests from ~15s to ~11s each in CI, because the hook now waits for the thing it actually needs (the Home heading) rather than all asset loading.
  • The alternative is slower CI. Without the bounded retry, this flake costs a guaranteed 60s hang, a red run, and a full manual re-run of the shard (~25 min) — that's the real "delayed continuous integration" we've been paying.

So the intent isn't "assume the app can be slow and wait longer" — total wait actually went down (30s bound vs 60s before), and the one retry only exists because a stuck boot is unrecoverable without a fresh navigation. Happy to file an issue for the underlying stuck-boot behavior so it gets root-caused properly, and to adjust the shape of this fix if you'd prefer a different approach.


Generated by Claude Code

@ggazzo ggazzo added this to the 8.8.0 milestone Jul 22, 2026
@ggazzo

ggazzo commented Jul 22, 2026

Copy link
Copy Markdown
Member

Closing — the root cause behind this flake was found and fixed in #41399 (ARCH-2272).

I traced the failing run (job 87223567263) via the Playwright trace: all 33 boot requests returned 200 in a ~3s burst, then ~58s of complete network silence with the loading spinner still up until the test timeout. The trace console showed the real error — ERR_INCOMPLETE_CHUNKED_ENCODING on POST /__meteor__/dynamic-import/fetch followed by TypeError: Failed to fetch from react-dom: a dynamic-import batch was truncated mid-body, the lazy module never loaded, and the boot wedged. Waiting longer would never have recovered it — nothing was in flight.

That is exactly the truncation #41399 fixes at the source (the traefik/Go net/http transport race), with a regression test and 3 green CI runs. With the truncation gone, this beforeEach retry is no longer needed for this cause, so closing.

If we still want the retry as defense-in-depth against a genuinely slow boot, worth reopening as a small HomeChannel.gotoHome() helper (encapsulating the toPass/goto) reused across suites rather than inline — but not required now.

@ggazzo ggazzo closed this Jul 22, 2026
@alfredodelfabro alfredodelfabro removed this from the 8.8.0 milestone Aug 26, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

7 participants