Skip to content

devtools: Attempt to rerun command before waiting for a page load (that might timeout)#10068

Merged
christian-bromann merged 1 commit intowebdriverio:mainfrom
nextlevelbeard:page-load-never-emitted
Mar 27, 2023
Merged

devtools: Attempt to rerun command before waiting for a page load (that might timeout)#10068
christian-bromann merged 1 commit intowebdriverio:mainfrom
nextlevelbeard:page-load-never-emitted

Conversation

@nextlevelbeard
Copy link
Member

@nextlevelbeard nextlevelbeard commented Mar 27, 2023

Proposed changes

When using automationProtocol devtools sometimes the Pupeteer execution context is destroyed.
Currently, when that happens, we attempt to wait for a page loaded event to be emitted, after it is emitted, we retry the command. I recently discovered a case where the page load is never emitted, therefore the tests would hang for a long time and then finally error with

Error: page load timeout
    at Timeout._onTimeout (file:///opt/atlassian/pipelines/agent/build/e2e/node_modules/devtools/build/devtoolsdriver.js:141:73)
    at listOnTimeout (node:internal/timers:568:17)
    at processTimers (node:internal/timers:511:7)

This same use case also benefits from an immediate retry of the command.
When rerun (without first waiting for the page load that is never emitted) the command successfully executes and returns the desired result.

I've implemented a 3 retry limit for a command, therefore the previous behavior is maintained but only after attempting the command again a couple of times.

You can see a demo for this with the actual use case in question.

retry.before.page.load.mov

Nothing was mocked for this demo, a real test executes a command with a destroyed context and then recovers after rerunning the command. This same demo would hang eventually with Error: page load timeout if these changes were not implemented, as the page load is never completed.

Types of changes

  • Bugfix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • Documentation update

Checklist

  • I have read the CONTRIBUTING doc
  • I have added tests that prove my fix is effective or that my feature works
  • [] I have added necessary documentation (if appropriate)
  • I have added proper type definitions for new commands (if appropriate)

Further comments

Reviewers: @webdriverio/project-committers

Copy link
Member

@christian-bromann christian-bromann left a comment

Choose a reason for hiding this comment

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

👍 LGTM

I am not sure if this change has other implications but if this fixes your use case, let's go with it! Thank you!

@christian-bromann christian-bromann added the PR: Polish 💅 PRs that contain improvements on existing features label Mar 27, 2023
@christian-bromann christian-bromann merged commit be004ed into webdriverio:main Mar 27, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

PR: Polish 💅 PRs that contain improvements on existing features

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants