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

page.queryObjects doesn't work as expected #4545

Closed
aslushnikov opened this issue Jun 8, 2019 · 3 comments · Fixed by #4581
Closed

page.queryObjects doesn't work as expected #4545

aslushnikov opened this issue Jun 8, 2019 · 3 comments · Fixed by #4581
Labels
bug chromium Issues with Puppeteer-Chromium upstream

Comments

@aslushnikov
Copy link
Contributor

Puppeteer: v1.17.0

Consider the following code snippet:

const puppeteer = require('puppeteer');

async function logRetainedArrays(page) {
  const prototypeHandle = await page.evaluateHandle(() => Array.prototype);
  const instancesHandle = await page.queryObjects(prototypeHandle);
  const retainedArrays = await page.evaluate(instances => instances, instancesHandle);
  console.log(retainedArrays);
  await instancesHandle.dispose();
}

(async() => {
  const browser = await puppeteer.launch();
  const page = await browser.newPage();
  await page.evaluate(() => {
    window.returnAnArray = () => [42];
    returnAnArray();
  });
  await logRetainedArrays(page);  // [ [ 42 ] ]
  await logRetainedArrays(page);  // [ [ 42 ] ]
  await logRetainedArrays(page);  // [ ]
  await browser.close();
})();
@aslushnikov
Copy link
Contributor Author

As @ak239 pointed out - looks like this has something to do with Array and Object literals.

@aslushnikov aslushnikov added bug chromium Issues with Puppeteer-Chromium upstream labels Jun 8, 2019
@aslushnikov
Copy link
Contributor Author

For the record: here's the retain chain:

image

@aslushnikov
Copy link
Contributor Author

The fix is out for review: https://chromium-review.googlesource.com/c/v8/v8/+/1649473

aslushnikov added a commit to aslushnikov/puppeteer that referenced this issue Jun 13, 2019
This roll includes:
- https://crrev.com/c/1652559 - inspector: fix queryObjects when page contains JSModuleNamespace
- https://crrev.com/c/1649473 - [heapprofiler] QueryObjects: do not return objects retained by feedback information
- https://crrev.com/c/1652155 - DevTools: teach page.printToPDF to return IO::Stream

References puppeteer#4563
Fix puppeteer#4545
aslushnikov added a commit that referenced this issue Jun 14, 2019
This roll includes:
- https://crrev.com/c/1652559 - inspector: fix queryObjects when page contains JSModuleNamespace
- https://crrev.com/c/1649473 - [heapprofiler] QueryObjects: do not return objects retained by feedback information
- https://crrev.com/c/1652155 - DevTools: teach page.printToPDF to return IO::Stream

References #4563
Fix #4545
llebout pushed a commit to llebout/chromium_v8 that referenced this issue Jun 16, 2019
…ck information

This was originally reported at puppeteer/puppeteer#4545

R=ulan, alph

Change-Id: I5134506e56cd40e49b358cd47590913b81013b6d
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/1649473
Commit-Queue: Andrey Lushnikov <lushnikov@chromium.org>
Reviewed-by: Alexei Filippov <alph@chromium.org>
Reviewed-by: Ulan Degenbaev <ulan@chromium.org>
Cr-Commit-Position: refs/heads/master@{#62129}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug chromium Issues with Puppeteer-Chromium upstream
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant