I use puppeteer-core with chrome-linux from https://storage.googleapis.com/chromium-browser-snapshots/Linux_x64/1095492/chrome-linux.zip.
this is my project:
project directory
// this is index.js
const puppeteer = require('puppeteer-core');
(async () => {
const browser = await puppeteer.launch({ headless: true, executablePath: './chrome-linux/chrome', args: ['--no-sandbox'] });
const page = await browser.newPage();
await page.goto('https://www.baidu.com/');
// Set screen size
await page.setViewport({ width: 1080, height: 1024 });
await browser.close();
})();
I excute node index.js, then the error came out.
(node:32513) UnhandledPromiseRejectionWarning: Error: Failed to launch the browser process!
./chrome-linux/chrome: symbol lookup error: ./chrome-linux/chrome: undefined symbol: gbm_bo_get_modifier
TROUBLESHOOTING: https://github.com/puppeteer/puppeteer/blob/main/docs/troubleshooting.md
at onClose (/opt/xxx/example/node_modules/puppeteer-core/lib/cjs/puppeteer/node/BrowserRunner.js:299:20)
at Interface.<anonymous> (/opt/xxx/example/node_modules/puppeteer-core/lib/cjs/puppeteer/node/BrowserRunner.js:287:24)
at Interface.emit (events.js:412:35)
at Interface.close (readline.js:530:8)
at Socket.onend (readline.js:254:10)
at Socket.emit (events.js:412:35)
at endReadableNT (internal/streams/readable.js:1333:12)
at processTicksAndRejections (internal/process/task_queues.js:82:21)
(Use `node --trace-warnings ...` to show where the warning was created)
(node:32513) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). To terminate the node process on unhandled promise rejection, use the CLI flag `--unhandled-rejections=strict` (see https://nodejs.org/api/cli.html#cli_unhandled_rejections_mode). (rejection id: 1)
(node:32513) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.
I could not launch Chrome. How can I fix this error? Thanks.
Puppeteer version
19.7.0
Node version
14.21.1
Package manager
npm
Package manager version
6.14.17
Operating system
Linux
Related
index.js file
import mongoose from "mongoose";
const DB_CONNECTION_URL =
"mongodb+srv://user:<password>#cluster0.cjkjw.mongodb.net/WhatsAppDB?retryWrites=true&w=majority";
const connectDB = () => {
console.log("DB trying to connect on " + new Date());
const options = {
keepAlive: 1,
maxPoolSize: 10,
useNewUrlParser: true,
autoReconnect: true,
useUnifiedTopology: true,
};
return mongoose.connect(DB_CONNECTION_URL, options);
};
export default connectDB;
eroor in my console
> whatsapp#1.0.0 start C:\Users\krish\onedrive\desktop\whatsapp_clone-mern_Stack\whatsapp-clone\server
> node ./node_modules/babel-cli/bin/babel-node.js --presets node8 ./server.js
DB trying to connect on Tue Nov 30 2021 21:31:43 GMT+0530 (India Standard Time)
(node:2944) UnhandledPromiseRejectionWarning: MongoParseError: option autoreconnect is not supported
at parseOptions (C:\Users\krish\onedrive\desktop\whatsapp_clone-mern_Stack\whatsapp-clone\server\node_modules\mongodb\src\connection_string.ts:358:11)
at new MongoClient (C:\Users\krish\onedrive\desktop\whatsapp_clone-mern_Stack\whatsapp-clone\server\node_modules\mongodb\src\mongo_client.ts:327:34)
at C:\Users\krish\onedrive\desktop\whatsapp_clone-mern_Stack\whatsapp-clone\server\node_modules\mongoose\lib\connection.js:779:16
at new Promise (<anonymous>)
at NativeConnection.Connection.openUri (C:\Users\krish\onedrive\desktop\whatsapp_clone-mern_Stack\whatsapp-clone\server\node_modules\mongoose\lib\connection.js:776:19)
at C:\Users\krish\onedrive\desktop\whatsapp_clone-mern_Stack\whatsapp-clone\server\node_modules\mongoose\lib\index.js:332:10
at C:\Users\krish\onedrive\desktop\whatsapp_clone-mern_Stack\whatsapp-clone\server\node_modules\mongoose\lib\helpers\promiseOrCallback.js:32:5
at new Promise (<anonymous>)
at promiseOrCallback (C:\Users\krish\onedrive\desktop\whatsapp_clone-mern_Stack\whatsapp-clone\server\node_modules\mongoose\lib\helpers\promiseOrCallback.js:31:10)
at Mongoose._promiseOrCallback (C:\Users\krish\onedrive\desktop\whatsapp_clone-mern_Stack\whatsapp-clone\server\node_modules\mongoose\lib\index.js:1153:10)
(Use `node --trace-warnings ...` to show where the warning was created)
(node:2944) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). To terminate the node process on unhandled promise rejection, use the CLI flag `--unhandled-rejections=strict` (see https://nodejs.org/api/cli.html#cli_unhandled_rejections_mode). (rejection id: 2)
(node:2944) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.
i need to connect to my localhost when i run this it shows the above error. i used poolsize instead of maxPoolsize and it shows the same error showing poolsize is not supported but when searched for the solution it shows there is some updation for the version and the new version doesnt support poolsize so i changed to maxpoolsize and it works but i didnt found any answer for the autorecconet i hope there is also an update for autoReconnet in the new version . but when i remove the auto reconnet code it works!! please help me to fix this!
My code works perfectly well with headless false, but when I change it to true I get this error :
(node:92024) UnhandledPromiseRejectionWarning: Error: Evaluation failed: TypeError: Cannot read property 'querySelectorAll' of null
at __puppeteer_evaluation_script__:7:17
at ExecutionContext._evaluateInternal (C:\wamp64\www\scrappingWithNodejs\testDiscordBot\node_modules\puppeteer\lib\cjs\puppeteer\common\ExecutionContext.js:221:19)
at processTicksAndRejections (internal/process/task_queues.js:95:5)
at async ExecutionContext.evaluate (C:\wamp64\www\scrappingWithNodejs\testDiscordBot\node_modules\puppeteer\lib\cjs\puppeteer\common\ExecutionContext.js:110:16)
at async getAllInfos (C:\wamp64\www\scrappingWithNodejs\testDiscordBot\index.js:28:12)
(Use `node --trace-warnings ...` to show where the warning was created)
(node:92024) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). To terminate the node process on unhandled promise rejection, use the CLI flag `--unhandled-rejections=strict` (see https://nodejs.org/api/cli.html#cli_unhandled_rejections_mode). (rejection id: 1)
(node:92024) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.
My code :
async function getAllInfos() {
const browser = await puppeteer.launch({ headless: true });
const page = await browser.newPage();
page.setDefaultNavigationTimeout(0);
await page.goto(`https://www.japanread.cc/`, {
waitUntil: ["load", "domcontentloaded", "networkidle0", "networkidle2"],
}); //se rendre sur une page
let trs = [];
trs = tbody.querySelectorAll("tr");//the error is here
I tried to put showMo, put several things in the "waitUntil" but I get nothing, I really don't understand.
Do you know what the problem is?
I'm using windows nanoserver container to launch puppeteer but it fails and I'm not sure what's wrong with my code
here's my docker file
FROM mcr.microsoft.com/windows/nanoserver:1903
COPY nodejs /windows/system32
CMD [ "node.exe" ]
COPY package.json ./
RUN npm install
# Bundle app source
COPY . .
ENTRYPOINT [ "node", "./server.js" ]
nodejs is a the node folder on my machine
and here's my package.json
{
"dependencies": {
"puppeteer": "^5.5.0",
"#axe-core/puppeteer": "^4.1.0"
}
}
and here's my server.js
const { AxePuppeteer } = require('#axe-core/puppeteer');
const puppeteer = require('puppeteer');
(async () => {
const browser = await puppeteer.launch({ headless: true,
ignoreDefaultArgs: ['--disable-extensions'],
args: ['--disable-dev-shm-usage', '--no-sandbox', '--disable-gpu', '--disable-setuid-sandbox'],
});
const page = await browser.newPage();
await page.goto('https://stackoverflow.com/');
const results = await new AxePuppeteer(page).analyze();
console.log(results);
await page.close();
await browser.close();
})();
So if I build the docker image then run
docker build -t chromeHeadless
docker run chromeHeadless
I get this error
(node:1228) UnhandledPromiseRejectionWarning: Error: Failed to launch the browser process!
TROUBLESHOOTING: https://github.com/puppeteer/puppeteer/blob/main/docs/troubleshooting.md
at onClose (C:\app\node_modules\puppeteer\lib\cjs\puppeteer\node\BrowserRunner.js:193:20) at Interface.<anonymous> (C:\app\node_modules\puppeteer\lib\cjs\puppeteer\node\BrowserRunner.js:183:68)
at Interface.emit (events.js:326:22)
at Interface.close (readline.js:424:8)
at Socket.onend (readline.js:202:10)
at Socket.emit (events.js:326:22)
at endReadableNT (_stream_readable.js:1244:12)
at processTicksAndRejections (internal/process/task_queues.js:80:21)
(Use `node --trace-warnings ...` to show where the warning was created)
(node:1228) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). To terminate the node process on unhandled promise rejection, use the CLI flag `--unhandled-rejections=strict` (see https://nodejs.org/api/cli.html#cli_unhandled_rejections_mode). (rejection id: 1)
(node:1228) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.
I have written a very simple puppyteerjs program :
const puppeteer = require('puppeteer');
(async () => {
const browser = await puppeteer.launch({ headless: false,
slowMo: 250 });
const page = await browser.newPage();
await page.goto('https://example.com');
await page.screenshot({path: 'example.png'});
await browser.close();
})();
PS D:\js\puppe> node .\screenshot.js
(node:2052) UnhandledPromiseRejectionWarning: Error: Failed to launch the browser process!
TROUBLESHOOTING: https://github.com/puppeteer/puppeteer/blob/master/docs/troubleshooting.md
at onClose (D:\js\puppe\node_modules\puppeteer\lib\Launcher.js:750:14)
at ChildProcess.helper.addEventListener (D:\js\puppe\node_modules\puppeteer\lib\Launcher.js:740:61)
at ChildProcess.emit (events.js:194:15)
at Process.ChildProcess._handle.onexit (internal/child_process.js:248:12)
(node:2052) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). (rejection id: 1)
(node:2052) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.
I tried this program with node version 12 and node version 10, I tried with a headless flag and also giving the path of chrome.exe file from node modules but it keeps on throwing the same exception.
My current environment is: windows 10 and node 10
When I run vue's npm run dev, I got this error:
(node:10871) UnhandledPromiseRejectionWarning: Unhandled promise rejection (rejection id: 1): Error: Exited with code 3
It works fine if I run in my computer with Node 6.11.3
But fails when I deploy to AWS EC2 with Node 6.11.3, or the Latest Node 9.something
If I run with latest node, I got a detail error message:
(node:10429) UnhandledPromiseRejectionWarning: Error: Exited with code 3
at ChildProcess.cp.once.code (/home/ubuntu/loan-vue-frontend/node_modules/opn/index.js:84:13)
at Object.onceWrapper (events.js:272:13)
at ChildProcess.emit (events.js:180:13)
at maybeClose (internal/child_process.js:936:16)
at Socket.stream.socket.on (internal/child_process.js:353:11)
at Socket.emit (events.js:180:13)
at Pipe._handle.close [as _onclose] (net.js:541:12)
(node:10429) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). (rejection id: 1)
(node:10429) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.
I have tried just installing a new project from scratch and it works.
Then I compare the code, and I found out I have this code (in a file called 'build/dev-server.js' :
var _resolve
var readyPromise = new Promise(resolve => {
_resolve = resolve
})
console.log('> Starting dev server...')
devMiddleware.waitUntilValid(() => {
console.log('> Listening at ' + uri + '\n')
// when env is testing, don't need open it
if (autoOpenBrowser && process.env.NODE_ENV !== 'testing') {
opn(uri)
}
_resolve()
})
var server = app.listen(port)
module.exports = {
ready: readyPromise,
close: () => {
server.close()
}
}
It seems to me the readyPromise is the cause of trouble.
But the only place that call that dev-server.js is in package.json:
"scripts": {
"dev": "node build/dev-server.js",
}
I suspect
ready: readyPromise,
is not right because 'ready' may not have a catch block. but I have no clue how I can fix it if that's the case.
Any idea?