Skip to content

fix(expect): honor timeout when the page is unresponsive - #42881

Closed
Dmitry Munda (dimkin-eu) wants to merge 1 commit into
microsoft:mainfrom
dimkin-eu:fix-expect-one-shot-timeout
Closed

Dmitry Munda (dimkin-eu) wants to merge 1 commit into
microsoft:mainfrom
dimkin-eu:fix-expect-one-shot-timeout

Conversation

@dimkin-eu

Copy link
Copy Markdown
Contributor

The one-shot expect check runs without a timeout so that expect(locator).toBeVisible({ timeout: 1 }) still passes when the element is already visible. It was not bounded at all, so when the page's event loop was blocked the call hung until the test timeout and reported Received: undefined.

This races the one-shot against the call's abort signal with a short grace period (1s): tiny timeouts keep working on responsive pages, and an unresponsive page now fails with the regular timeout error. Same class of fix as #40901 for screenshots.

Fixes #42880

The one-shot expect check is allowed to finish after the deadline, so that
`expect(locator).toBeVisible({ timeout: 1 })` passes when the element is
already visible. It was not bounded at all, though: when the page's event
loop was blocked, the call hung until the test timeout and reported
`Received: undefined` instead of a timeout. Give the one-shot a short grace
period after the call is aborted, then fail with the regular timeout error.

Fixes microsoft#42880
@github-actions

Copy link
Copy Markdown
Contributor

Test results for "tests 1"

5 flaky ⚠️ [chromium-library] › library/video.spec.ts:762 › screencast › should work with video+trace `@realtime-time-library-chromium-linux`
⚠️ [chromium-library] › library/chromium/chromium.spec.ts:436 › should produce network events, routing, and annotations for Service Worker (advanced) `@chromium-ubuntu-22.04-node24`
⚠️ [chromium-library] › library/inspector/cli-codegen-2.spec.ts:202 › cli codegen › should upload a file via hidden input triggered by button `@chromium-ubuntu-22.04-node22`
⚠️ [firefox-library] › library/browsercontext-cookies-third-party.spec.ts:257 › third party 'Partitioned;' cookies `@firefox-ubuntu-22.04-node20`
⚠️ [firefox-library] › library/browsercontext-cookies-third-party.spec.ts:470 › top level 'Partitioned;' cookie and same origin iframe `@firefox-ubuntu-22.04-node20`

51208 passed, 1234 skipped


Merge workflow run.

@github-actions

Copy link
Copy Markdown
Contributor

Test results for "MCP"

8705 passed, 1474 skipped


Merge workflow run.

@dgozman

Copy link
Copy Markdown
Collaborator

I am not sure we want this. The issue is a rare outlier, I'd prefer to keep things as is for now, until we see this is a common enough usecase. Thank you for the PR.

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.

[Bug]: expect(locator).toBeVisible() ignores its timeout when the page is unresponsive; hangs until test timeout

2 participants