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

[Bug]: regression on browser.waitForTarget time out on v16, target.type() not returning valid value #8800

Closed
danielcaldas opened this issue Aug 17, 2022 · 4 comments · Fixed by #8807 or #8808
Assignees

Comments

@danielcaldas
Copy link

Bug description

Steps to reproduce the problem:

Run the following:

const browser = await puppeteer.launch({
    headless: false,
    args: [
      `--disable-extensions-except=${pathToExtension}`,
      `--load-extension=${pathToExtension}`,
    ],
  });
  const backgroundPageTarget = await browser.waitForTarget(
    target => target.type() === 'service_worker'
  );

See the statement waitForTarget will timeout on v16.1.1. Same code snippet was working for puppeteer v15.5.0. I believe the target worker is no longer being considered a target.

Puppeteer version

16.1.1

Node.js version

14.16.1

npm version

8.1.4

What operating system are you seeing the problem on?

macOS

Relevant log output

TimeoutError: waiting for target failed: timeout 30000ms exceeded

      45 |   let extensionTarget;
      46 |
    > 47 |   await browser.waitForTarget(x => x.type() === 'service_worker' || x.type() === 'worker');
         |                 ^
      48 |   const targets = await browser.targets();
      49 |   extensionTarget = targets.find(target => target.type() === 'service_worker');
      50 |

      at waitWithTimeout (../node_modules/puppeteer/src/common/util.ts:394:24)
      at Browser.waitForTarget (../node_modules/puppeteer/src/common/Browser.ts:663:35)
      at boot (../e2e/boot.js:47:17)
      at Object.<anonymous> (../e2e/tests/importExport.spec.js:24:21)

console.loging the target.type I get only browser and page:

console.info
    !!!!!!!!!! browser

      at ../e2e/boot.js:47:44
          at Array.forEach (<anonymous>)

  console.info
    !!!!!!!!!! page

      at ../e2e/boot.js:47:44
          at Array.forEach (<anonymous>)
@OrKoN
Copy link
Collaborator

OrKoN commented Aug 17, 2022

Thanks for the report. Could you provide an executable repro? We do have a test that waits for the service_worker and that is passing: https://github.com/puppeteer/puppeteer/blob/main/test/src/target.spec.ts#L186 so I wonder what is difference. How do you know that the type() is returning a wrong value? it looks like the service worker target is not detected?

danielcaldas added a commit to tweak-extension/puppeteer-test-browser-ext that referenced this issue Aug 17, 2022
@danielcaldas
Copy link
Author

Yes. You can check this repo - tweak-extension/puppeteer-test-browser-ext#2. The setup is straightforward, the example is very minimal.

@OrKoN OrKoN self-assigned this Aug 17, 2022
OrKoN added a commit that referenced this issue Aug 17, 2022
OrKoN added a commit that referenced this issue Aug 17, 2022
OrKoN added a commit that referenced this issue Aug 17, 2022
OrKoN added a commit that referenced this issue Aug 17, 2022
OrKoN added a commit that referenced this issue Aug 17, 2022
OrKoN added a commit that referenced this issue Aug 17, 2022
@nyqykk
Copy link

nyqykk commented Aug 18, 2022

i get the same problem, it helps me!

@OrKoN
Copy link
Collaborator

OrKoN commented Aug 18, 2022

@danielcaldas thanks for the repro! It looks like we were missing test coverage for this.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
3 participants