Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

IPLAYER-40770: Fix "No inspectable targets" error when connecting to chrome-remote-interface #62

Merged
merged 16 commits into from
Oct 26, 2021

Conversation

anthonyec
Copy link
Contributor

@anthonyec anthonyec commented Oct 25, 2021

Problem

Launching Chrome and connecting to the Chrome Dev Protocol (CDP) are separate actions, and are susceptible to a race condition. This race condition occurs if Chrome has launched but Chrome Dev Protocol is not yet ready.

If you try to connect to the Chrome Dev Protocol before it is ready, it will throw an error:

Error: No inspectable targets

We have been experiencing this in our iPlayer CI.

Solution

Wait for the Chrome Dev Protocol to be ready before trying to connect to it.

Chrome provides an endpoint (/json/list) that lists inspectable targets. If the CDP is not ready, the list will be an empty array. We can poll this endpoint until the list is populated. This is basically the solution that has been suggested in the bug report for the chrome-launcher library. However, there hasn't been an official fix merged yet.

Changes

  • Install nock to mock requests
  • Create simple GET request functionality (no need for third-party library)
  • Add waitForInspectableTarget before trying to connect to CDP

Links

@anthonyec anthonyec changed the title Chrome launcher CDP retry Fix "No inspectable targets" error when connecting to chrome-remote-interface Oct 25, 2021
@anthonyec anthonyec changed the title Fix "No inspectable targets" error when connecting to chrome-remote-interface IPLAYER-40770: Fix "No inspectable targets" error when connecting to chrome-remote-interface Oct 26, 2021
@anthonyec anthonyec marked this pull request as ready for review October 26, 2021 10:37
Copy link
Contributor

@andymsuk andymsuk left a comment

Choose a reason for hiding this comment

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

Presumably everything still works as expected when running a11y-tests-web locally on your Mac too?

@anthonyec
Copy link
Contributor Author

anthonyec commented Oct 26, 2021

Presumably everything still works as expected when running a11y-tests-web locally on your Mac too?

@andymsuk yep, all works locally

@anthonyec anthonyec merged commit c49964b into master Oct 26, 2021
@anthonyec anthonyec deleted the IPLAYER-40770-chrome-launcher-cdp-retry branch October 26, 2021 13:01
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.

None yet

3 participants