question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

page.goto returns null periodically

See original GitHub issue

Steps to reproduce

Similar/same as: #1391

Tell us about your environment:

What steps will reproduce the problem?

const browser = await puppeteer.launch();

const page = await browser.newPage();

for (var i = 0; i < 15; i++) {
  const r = await page.goto('https://www.microsoft.com/en-gb/store/d/xbox-one-s-1tb-console-playerunknowns-battlegrounds-bundle/908z9jn5cnh2/gz4w?cid=msft_web_collection', { waitUntil: 'domcontentloaded' });

  console.log(r.ok());
}

await browser.close();

What is the expected result?

true outputted 15 times

What happens instead?

Sometimes true 15 times, sometimes TypeError: Cannot read property 'ok' of null

It works as expected on 1.2.0, but fails on 1.3.0

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Reactions:1
  • Comments:27 (7 by maintainers)

github_iconTop GitHub Comments

13reactions
bluepetercommented, Jul 26, 2018

Here’s a bit of a workaround until this is fixed:

let fullResponse = await chromePage.goto("https://wherever.com");
if (fullResponse === null) {
  console.log("Got null, trying wait.");
  fullResponse = await chromePage.waitForResponse(() => true);
}
3reactions
Schakacommented, Jan 11, 2021
if (response === null) {
    response = await page.waitForResponse(() => true);
}

This will return the first response you’re getting once interception starts. This will NOT return the intial request you’re actually looking. So if you actually need that request, you’re out of luck unless you use an incognito tab.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Puppeteer - Returning null content to my scrape - Stack Overflow
The page.waitForSelector() method returns the ElementHandle if it finds the element, otherwise it throws an error. As such, we can use this ...
Read more >
Puppeteer documentation - DevDocs
Defaults to false . defaultViewport <?Object> Sets a consistent viewport for each page. Defaults to an 800x600 viewport. null disables the default viewport....
Read more >
utils.puppeteer - Apify SDK
Extended version of Puppeteer's page.goto() allowing to perform requests with ... null = null - Name or id of the Key-Value store where...
Read more >
API Reference — Pyppeteer 0.0.25 documentation
Navigate to the previous page in history. Available options are same as goto() method. If cannot go back, return None .
Read more >
Page | Playwright - CukeTest
newPage(); await page.goto('https://example.com'); await page.screenshot({path: ... If no elements match the selector, the return value resolves to null .
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found