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]: using exposeFunction on a page with an iframe pointing to a pdf causes hang #12172

Closed
2 tasks
eoghanmurray opened this issue Mar 28, 2024 · 7 comments
Closed
2 tasks

Comments

@eoghanmurray
Copy link

Minimal, reproducible example

import puppeteer from 'puppeteer'; // TS/ESM are all supported.

(async () => {
  const browser = await puppeteer.launch();
  const page = await browser.newPage();
  await page.goto('about:blank');

  // assuming a valid PDF
  await page.setContent('<html><body><iframe src="some-doc.pdf"></iframe></body></html>')

  await page.exposeFunction('test', () => { console.log('test'); });
  // !!! don't get to here
  await browser.close();
})();

Error string

no error (hangs)

Bug behavior

  • Flaky
  • PDF

Background

This is in a suite of tests and causes the tests to hang
eoghanmurray/rrweb@845bf5c#diff-f822a25730eb990747d0f997cbcbf61789e7924c84988c09f3666935d5d6a577R624

Expectation

not to try to inject the 'test' function into the iframe document, as it isn't a regular javascript environment.

additionally, I expected it not to hang when failing to do so, but to have some sort of timeout to indicate that the injection failed to complete

Reality

tests hang

Puppeteer configuration file (if used)

No response

Puppeteer version

22.6.1

Node version

27.7.1

Package manager

yarn

Package manager version

1.2.3

Operating system

Linux

Copy link

This issue has an outdated Puppeteer version: 22.6.1. Please verify your issue on the latest 22.6.2 version. Then update the form accordingly.


Analyzer run

@eoghanmurray
Copy link
Author

22.6.2 not released at https://classic.yarnpkg.com/en/package/puppeteer yet

@OrKoN
Copy link
Collaborator

OrKoN commented Mar 28, 2024

Not able to reproduce on Mac with:

import puppeteer from 'puppeteer'; // TS/ESM are all supported.

(async () => {
  const browser = await puppeteer.launch();
  const page = await browser.newPage();
  await page.goto('about:blank');

  await page.setContent('<html><body><iframe src="https://www.w3.org/WAI/ER/tests/xhtml/testfiles/resources/pdf/dummy.pdf"></iframe></body></html>')
  await page.exposeFunction('test', () => { console.log('test'); });
  // !!! don't get to here
  await browser.close();
})();

@OrKoN
Copy link
Collaborator

OrKoN commented Mar 28, 2024

Also, not with using a file URL to a local file. Perhaps the issue is specific to Linux.

@OrKoN
Copy link
Collaborator

OrKoN commented Mar 28, 2024

Able to repro with a PDF served from a local http server.

@OrKoN
Copy link
Collaborator

OrKoN commented Mar 28, 2024

The workaround for now could be to filter out all iframe targets with url about:blank:

    targetFilter: t => {
        return !(t.url() === 'about:blank' && t.type() === 'iframe')
    }

@OrKoN
Copy link
Collaborator

OrKoN commented Mar 29, 2024

Very likely related to #10696

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

No branches or pull requests

2 participants