Communities

Writing
Writing
Codidact Meta
Codidact Meta
The Great Outdoors
The Great Outdoors
Photography & Video
Photography & Video
Scientific Speculation
Scientific Speculation
Cooking
Cooking
Electrical Engineering
Electrical Engineering
Judaism
Judaism
Languages & Linguistics
Languages & Linguistics
Software Development
Software Development
Mathematics
Mathematics
Christianity
Christianity
Code Golf
Code Golf
Music
Music
Physics
Physics
Linux Systems
Linux Systems
Power Users
Power Users
Tabletop RPGs
Tabletop RPGs
Community Proposals
Community Proposals
tag:snake search within a tag
answers:0 unanswered questions
user:xxxx search by author id
score:0.5 posts with 0.5+ score
"snake oil" exact phrase
votes:4 posts with 4+ votes
created:<1w created < 1 week ago
post_type:xxxx type of post
Search help
Notifications
Mark all as read See all your notifications »
Q&A

Welcome to Software Development on Codidact!

Will you help us build our independent community of developers helping developers? We're small and trying to grow. We welcome questions about all aspects of software development, from design to code to QA and more. Got questions? Got answers? Got code you'd like someone to review? Please join us.

Post History

60%
+1 −0
Q&A Tackling net::ERR_NAME_NOT_RESOLVED and timeout error on browser object creation when using Puppeteer

Used to work with PhantomJS. Want to upgrade to Puppeteer. Started with some code: "use strict"; const puppeteer = require("puppeteer"); const capture = async () => { let browser; try {...

1 answer  ·  posted 3y ago by sbirl‭  ·  last activity 7d ago by Alexei‭

#2: Post edited by user avatar Alexei‭ · 2022-03-19T06:04:54Z (almost 3 years ago)
improved the title + minor fixes
  • new to node.js and puppeteer
  • Tackling net::ERR_NAME_NOT_RESOLVED and timeout error on browser object creation when using Puppeteer
  • Hey all:
  • Used to working with PhantomJS. Want to upgrade to Puppeteer. Started with some code:
  • ```
  • "use strict";
  • const puppeteer = require("puppeteer");
  • const capture = async () => {
  • let browser;
  • try {
  • console.time('myTimer');
  • console.info("Opening browser ...");
  • const browser = await puppeteer.launch({
  • headless:true,'ignoreHTTPSErrors':true,devtools:false
  • });
  • const page = await browser.newPage();
  • page.on('console', (msg) => console.log('DEBUG:', msg.text()) );
  • console.info("browser instance created.");
  • await page.evaluate(() => console.log(`URL="${location.href}".`));
  • await page.goto("https://www.chunkbase.com/apps/seed-map");
  • // await page.goto("https://checkip.amazonaws.com/");
  • await page.evaluate(() => console.log(`URL="${location.href}".`));
  • console.info("getting webpage dimensions.");
  • const getDimensions = await page.evaluate(() => {
  • return {
  • pxH: document.documentElement.clientHeight,
  • pxW: document.documentElement.clientWidth,
  • scale: window.devicePixelRatio
  • };
  • });
  • console.info("Dimensions: ", getDimensions);
  • console.info("capturing.");
  • await page.screenshot({ path:"D:/screenshot.png", type:"png", fullPage:false });
  • console.timeEnd('myTimer');
  • } catch (err) {
  • console.warn("Could not create a browser instance: ", err);
  • return;
  • } finally {
  • await browser.close();
  • }
  • };
  • capture();
  • ```
  • **Output:**
  • ```
  • Opening browser ...
  • browser instance created.
  • DEBUG: URL="about:blank".
  • DEBUG: [.WebGL-000022F60095A300]GL Driver Message (OpenGL, Performance, GL_CLOSE_PATH_NV, High): GPU stall due to ReadPixels
  • DEBUG: fun-hooks: referenced 'adpod' but it was never created
  • DEBUG: %cVideoManagerComponent::noStickyPlaylistOrSekindo color: #999; font-weight: bold; JSHandle@object
  • DEBUG: %cBaseDynamicAdsInjector::_logDensityInfo color: #999; font-weight: bold; JSHandle@object
  • DEBUG: fun-hooks: referenced 'checkAdUnitSetup' but it was never created
  • DEBUG: fun-hooks: referenced 'checkAdUnitSetup' but it was never created
  • DEBUG: fun-hooks: referenced 'checkAdUnitSetup' but it was never created
  • DEBUG: Failed to load resource: net::ERR_NAME_NOT_RESOLVED
  • DEBUG: Failed to load resource: net::ERR_NAME_NOT_RESOLVED
  • DEBUG: Failed to load resource: net::ERR_NAME_NOT_RESOLVED
  • DEBUG: Failed to load resource: net::ERR_NAME_NOT_RESOLVED
  • DEBUG: Failed to load resource: net::ERR_NAME_NOT_RESOLVED
  • DEBUG: Failed to load resource: net::ERR_NAME_NOT_RESOLVED
  • DEBUG: Failed to load resource: net::ERR_NAME_NOT_RESOLVED
  • DEBUG: Failed to load resource: net::ERR_NAME_NOT_RESOLVED
  • DEBUG: Failed to load resource: net::ERR_NAME_NOT_RESOLVED
  • DEBUG: Failed to load resource: net::ERR_NAME_NOT_RESOLVED
  • DEBUG: Failed to load resource: net::ERR_NAME_NOT_RESOLVED
  • DEBUG: Failed to load resource: net::ERR_NAME_NOT_RESOLVED
  • DEBUG: Failed to load resource: net::ERR_NAME_NOT_RESOLVED
  • DEBUG: Failed to load resource: net::ERR_NAME_NOT_RESOLVED
  • Could not create a browser instance: TimeoutError: Navigation timeout of 30000 ms exceeded
  • at ~\node_modules\puppeteer\lib\cjs\puppeteer\common\LifecycleWatcher.js:108:111 ~\scripts\chunkbase.js:51
  • await browser.close();
  • ^
  • TypeError: Cannot read properties of undefined (reading 'close')
  • ```
  • **Notes:**
  • 1. With the current `page.goto` code Puppeteer
  • 1. Throws a lot of output.
  • 1. Times out after 30 seconds.
  • 1. The page dimensions are skipped.
  • 1. The screen capture never occurs.
  • 1. If I set `headless` to false, the page renders for the most part. Some parts dont load.
  • 1. If I swap around the URLs in the `page.goto` Puppeteer
  • 1. works fast without a ton of `DEBUG`s in output.
  • 1. The page dimensions are calculated.
  • 1. The screen capture occurs.
  • **Questions:**
  • 1. What's the proper way to initialize `browser` to correct the `.close()` error within the try-catch?
  • 1. How can I troubleshoot this further? Especially where these `net::ERR_NAME_NOT_RESOLVED` errors come from (is it DNS-related)?
  • Open to all sorts of suggestions, on-line reading material, etc.
  • Thanks.
  • Used to work with PhantomJS. Want to upgrade to Puppeteer. Started with some code:
  • ```
  • "use strict";
  • const puppeteer = require("puppeteer");
  • const capture = async () => {
  • let browser;
  • try {
  • console.time('myTimer');
  • console.info("Opening browser ...");
  • const browser = await puppeteer.launch({
  • headless:true,'ignoreHTTPSErrors':true,devtools:false
  • });
  • const page = await browser.newPage();
  • page.on('console', (msg) => console.log('DEBUG:', msg.text()) );
  • console.info("browser instance created.");
  • await page.evaluate(() => console.log(`URL="${location.href}".`));
  • await page.goto("https://www.chunkbase.com/apps/seed-map");
  • // await page.goto("https://checkip.amazonaws.com/");
  • await page.evaluate(() => console.log(`URL="${location.href}".`));
  • console.info("getting webpage dimensions.");
  • const getDimensions = await page.evaluate(() => {
  • return {
  • pxH: document.documentElement.clientHeight,
  • pxW: document.documentElement.clientWidth,
  • scale: window.devicePixelRatio
  • };
  • });
  • console.info("Dimensions: ", getDimensions);
  • console.info("capturing.");
  • await page.screenshot({ path:"D:/screenshot.png", type:"png", fullPage:false });
  • console.timeEnd('myTimer');
  • } catch (err) {
  • console.warn("Could not create a browser instance: ", err);
  • return;
  • } finally {
  • await browser.close();
  • }
  • };
  • capture();
  • ```
  • **Output:**
  • ```
  • Opening browser ...
  • browser instance created.
  • DEBUG: URL="about:blank".
  • DEBUG: [.WebGL-000022F60095A300]GL Driver Message (OpenGL, Performance, GL_CLOSE_PATH_NV, High): GPU stall due to ReadPixels
  • DEBUG: fun-hooks: referenced 'adpod' but it was never created
  • DEBUG: %cVideoManagerComponent::noStickyPlaylistOrSekindo color: #999; font-weight: bold; JSHandle@object
  • DEBUG: %cBaseDynamicAdsInjector::_logDensityInfo color: #999; font-weight: bold; JSHandle@object
  • DEBUG: fun-hooks: referenced 'checkAdUnitSetup' but it was never created
  • DEBUG: fun-hooks: referenced 'checkAdUnitSetup' but it was never created
  • DEBUG: fun-hooks: referenced 'checkAdUnitSetup' but it was never created
  • DEBUG: Failed to load resource: net::ERR_NAME_NOT_RESOLVED
  • DEBUG: Failed to load resource: net::ERR_NAME_NOT_RESOLVED
  • DEBUG: Failed to load resource: net::ERR_NAME_NOT_RESOLVED
  • DEBUG: Failed to load resource: net::ERR_NAME_NOT_RESOLVED
  • DEBUG: Failed to load resource: net::ERR_NAME_NOT_RESOLVED
  • DEBUG: Failed to load resource: net::ERR_NAME_NOT_RESOLVED
  • DEBUG: Failed to load resource: net::ERR_NAME_NOT_RESOLVED
  • DEBUG: Failed to load resource: net::ERR_NAME_NOT_RESOLVED
  • DEBUG: Failed to load resource: net::ERR_NAME_NOT_RESOLVED
  • DEBUG: Failed to load resource: net::ERR_NAME_NOT_RESOLVED
  • DEBUG: Failed to load resource: net::ERR_NAME_NOT_RESOLVED
  • DEBUG: Failed to load resource: net::ERR_NAME_NOT_RESOLVED
  • DEBUG: Failed to load resource: net::ERR_NAME_NOT_RESOLVED
  • DEBUG: Failed to load resource: net::ERR_NAME_NOT_RESOLVED
  • Could not create a browser instance: TimeoutError: Navigation timeout of 30000 ms exceeded
  • at ~\node_modules\puppeteer\lib\cjs\puppeteer\common\LifecycleWatcher.js:108:111 ~\scripts\chunkbase.js:51
  • await browser.close();
  • ^
  • TypeError: Cannot read properties of undefined (reading 'close')
  • ```
  • **Notes:**
  • 1. With the current `page.goto` code Puppeteer
  • 1. Throws a lot of output.
  • 1. Times out after 30 seconds.
  • 1. The page dimensions are skipped.
  • 1. The screen capture never occurs.
  • 1. If I set `headless` to false, the page renders for the most part. Some parts dont load.
  • 1. If I swap around the URLs in the `page.goto` Puppeteer
  • 1. works fast without a ton of `DEBUG`s in output.
  • 1. The page dimensions are calculated.
  • 1. The screen capture occurs.
  • **Questions:**
  • 1. What's the proper way to initialize `browser` to correct the `.close()` error within the try-catch?
  • 1. How can I troubleshoot this further? Especially where these `net::ERR_NAME_NOT_RESOLVED` errors come from (is it DNS-related)?
  • Open to all sorts of suggestions, on-line reading material, etc.
  • Thanks.
#1: Initial revision by user avatar sbirl‭ · 2022-03-18T23:26:36Z (almost 3 years ago)
new to node.js and puppeteer
Hey all:
Used to working with PhantomJS.  Want to upgrade to Puppeteer.  Started with some code:
```
"use strict";
const puppeteer = require("puppeteer");

const capture = async () => {
	let browser;
	try {
		console.time('myTimer');
		console.info("Opening browser ...");
		const browser = await puppeteer.launch({
			headless:true,'ignoreHTTPSErrors':true,devtools:false
		});
		const page = await browser.newPage();

		page.on('console', (msg) => console.log('DEBUG:', msg.text()) );
		console.info("browser instance created.");

		await page.evaluate(() => console.log(`URL="${location.href}".`));
		await page.goto("https://www.chunkbase.com/apps/seed-map");
	//	await page.goto("https://checkip.amazonaws.com/");
		await page.evaluate(() => console.log(`URL="${location.href}".`));

		console.info("getting webpage dimensions.");
		const getDimensions = await page.evaluate(() => {
			return {
				pxH: document.documentElement.clientHeight,
				pxW: document.documentElement.clientWidth,
				scale: window.devicePixelRatio
			};
		});
		console.info("Dimensions: ", getDimensions);

		console.info("capturing.");
		await page.screenshot({ path:"D:/screenshot.png", type:"png", fullPage:false });
		console.timeEnd('myTimer');
	} catch (err) {
		console.warn("Could not create a browser instance: ", err);
		return;
	} finally {
		await browser.close();
	}
};
capture();
```
**Output:**
```
Opening browser ...
browser instance created.
DEBUG: URL="about:blank".
DEBUG: [.WebGL-000022F60095A300]GL Driver Message (OpenGL, Performance, GL_CLOSE_PATH_NV, High): GPU stall due to ReadPixels
DEBUG: fun-hooks: referenced 'adpod' but it was never created
DEBUG: %cVideoManagerComponent::noStickyPlaylistOrSekindo  color: #999; font-weight: bold; JSHandle@object
DEBUG: %cBaseDynamicAdsInjector::_logDensityInfo  color: #999; font-weight: bold; JSHandle@object
DEBUG: fun-hooks: referenced 'checkAdUnitSetup' but it was never created
DEBUG: fun-hooks: referenced 'checkAdUnitSetup' but it was never created
DEBUG: fun-hooks: referenced 'checkAdUnitSetup' but it was never created
DEBUG: Failed to load resource: net::ERR_NAME_NOT_RESOLVED
DEBUG: Failed to load resource: net::ERR_NAME_NOT_RESOLVED
DEBUG: Failed to load resource: net::ERR_NAME_NOT_RESOLVED
DEBUG: Failed to load resource: net::ERR_NAME_NOT_RESOLVED
DEBUG: Failed to load resource: net::ERR_NAME_NOT_RESOLVED
DEBUG: Failed to load resource: net::ERR_NAME_NOT_RESOLVED
DEBUG: Failed to load resource: net::ERR_NAME_NOT_RESOLVED
DEBUG: Failed to load resource: net::ERR_NAME_NOT_RESOLVED
DEBUG: Failed to load resource: net::ERR_NAME_NOT_RESOLVED
DEBUG: Failed to load resource: net::ERR_NAME_NOT_RESOLVED
DEBUG: Failed to load resource: net::ERR_NAME_NOT_RESOLVED
DEBUG: Failed to load resource: net::ERR_NAME_NOT_RESOLVED
DEBUG: Failed to load resource: net::ERR_NAME_NOT_RESOLVED
DEBUG: Failed to load resource: net::ERR_NAME_NOT_RESOLVED
Could not create a browser instance:  TimeoutError: Navigation timeout of 30000 ms exceeded
    at ~\node_modules\puppeteer\lib\cjs\puppeteer\common\LifecycleWatcher.js:108:111 ~\scripts\chunkbase.js:51
                await browser.close();
                              ^
TypeError: Cannot read properties of undefined (reading 'close')
```
**Notes:**
1. With the current `page.goto` code Puppeteer
    1. Throws a lot of output.
    1. Times out after 30 seconds.
    1. The page dimensions are skipped.
    1. The screen capture never occurs.
    1. If I set `headless` to false, the page renders for the most part.  Some parts dont load.
1. If I swap around the URLs in the `page.goto` Puppeteer
    1. works fast without a ton of `DEBUG`s in output.
    1. The page dimensions are calculated.
    1. The screen capture occurs.

**Questions:**
1. What's the proper way to initialize `browser` to correct the `.close()` error within the try-catch?
1. How can I troubleshoot this further?  Especially where these `net::ERR_NAME_NOT_RESOLVED` errors come from (is it DNS-related)?

Open to all sorts of suggestions, on-line reading material, etc.

Thanks.