Selenium-WebDriver UnhandeledPromiseRejectionWarning Error - node.js

This is my first time using Selenium web driver. I am having issues 'getting' a web address. Here is my code:
const {Builder, By, Key, until} = require('selenium-webdriver'),
app = require('express'),
express = app();
let driver = new Builder().forBrowser('chrome').build();
driver.get('https://google.com'); //<---- known bug(doesn't open proper page)
So there, I am just trying to open google.com Please tell me what I'm doing wrong. Anyway, here's the error when I do, node app.js:
DevTools listening on ws://127.0.0.1:12825/devtools/browser/cd5a8eae-4ff0-482e-9f80-cf49f4c3f794
(node:11584) UnhandledPromiseRejectionWarning: WebDriverError: unknown error: Runtime.executionContextCreated has invalid 'context': {"auxData":{"frameId":"A07868DB3EACD45E5235CB0DA6162B30","isDefault":true,"type":"default"},"id":1,"name":"","origin":"://"}
(Session info: chrome=70.0.3538.110)
(Driver info: chromedriver=2.9.248315,platform=Windows NT 6.3 x86_64)
at Object.checkLegacyResponse (C:\Users\Ben Levy\Desktop\bot\node_modules\selenium-webdriver\lib\error.js:585:15)
at parseHttpResponse (C:\Users\Ben Levy\Desktop\bot\node_modules\selenium-webdriver\lib\http.js:533:13)
at Executor.execute (C:\Users\Ben Levy\Desktop\bot\node_modules\selenium-webdriver\lib\http.js:468:26)
at process._tickCallback (internal/process/next_tick.js:68:7)
(node:11584) 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:11584) [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.
Thanks!

From the error
(Session info: chrome=70.0.3538.110)
(Driver info: chromedriver=2.9.248315,platform=Windows NT 6.3 x86_64)
I can see it running old chromedriver 2.9 and not compatible with the Chrome, download the latest version from here.

Related

Telegraf telegram framework: Base64 images in sendMediagroup: Error: 400: Bad Request: wrong remote file identifier specified: Wrong character

Telegraf.js Version: ^4.8.5
Node.js Version: 14.15.4
Operating System: Win 10 x64, VSCode latest
What happens:
ctx.replyWithMediaGroup can't send base64 images (media group must have a caption
Hot to send correctly?
Expected
Send images in a mediagroup
Code to reproduce:
Pastebin because it's long
It has base64 images embedded.
Just replace your token and the bot is ready to be tested and reproduce error.
Notes:
Base64 images are valid.
Pasting to any base64 to image online service produces this:
Details of the error:
(node:30228) UnhandledPromiseRejectionWarning: Error: 400: Bad Request: wrong remote file identifier specified: Wrong character in the string
at Telegram.callApi (c:\pers\sometesttg\node_modules\telegraf\lib\core\network\client.js:265:19)
at processTicksAndRejections (internal/process/task_queues.js:95:5)
(Use node --trace-warnings ... to show where the warning was created)
<node_internals>/internal/process/warning.js:44
(node:30228) 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_internals>/internal/process/warning.js:44
(node:30228) [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.

Puppeteer cluster sometimes cannot start in k8s

I'm using puppeteer with puppeteer-cluster, this is deployed on k8s and everything works great.
The only problem I'm having is that sometimes the pod won't start, and throws this exception:
(node:24) UnhandledPromiseRejectionWarning: Error: Unable to launch browser, error message: read ECONNRESET
at Cluster.<anonymous> (/app/node_modules/puppeteer-cluster/dist/Cluster.js:107:23)
at Generator.throw (<anonymous>)
at rejected (/app/node_modules/puppeteer-cluster/dist/Cluster.js:6:65)
at process._tickCallback (internal/process/next_tick.js:68:7)
followed by:
(node:24) 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)
and:
(node:24) [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.
This doesn't affect me functionally considerably, as k8s just creates a new pod (which works fine), but I'd like to understand what happens, and if I can fix it.
Cluster initialization code:
const cluster = await Cluster.launch({
concurrency: Cluster.CONCURRENCY_CONTEXT,
maxConcurrency: Constants.CONFIG.URL_CONCURRENCY,
retryLimit: Constants.CONFIG.CLUSTER_INTERNAL_RETRIES,
timeout: Constants.CONFIG.MAX_TIMEOUT
puppeteerOptions: { ignoreHTTPSErrors: true, args: ["--no-sandbox"] }
});
versions:
"puppeteer": "^2.0.0",
"puppeteer-cluster": "^0.18.0",

nodejs Why can't I use puppeteer-core?

I am trying to use puppeteer-core and chrome-aws-lambda so I can upload my function to aws lambda but I get an error when running my script locally, I have tried uninstalling and reinstalling the modules but I still get an error, this is my code
const chrome = require('chrome-aws-lambda');
const puppeteer = require('puppeteer-core');
(async () => {
const browser = await puppeteer.launch({
args: chrome.args,
executablePath: "/home/usern/Desktop/serverless/node_modules/chrome-aws-lambda/bin/chromium-75.0.3765.0.br",
headless: chrome.headless,
});
const page = await browser.newPage();
await page.goto('https://example.com');
await browser.close();
})();
It gives me this error, im not sure what to do to fix it
(node:17811) UnhandledPromiseRejectionWarning: Error: Failed to launch chrome!
/home/connor/Desktop/serverless/node_modules/chrome-aws-lambda/bin/chromium-75.0.3765.0.br: 1: /home/connor/Desktop/serverless/node_modules/chrome-aws-lambda/bin/chromium-75.0.3765.0.br: ���m�����鹲o�b�Vb%�]!yb: not found
/home/connor/Desktop/serverless/node_modules/chrome-aws-lambda/bin/chromium-75.0.3765.0.br: 1: /home/connor/Desktop/serverless/node_modules/chrome-aws-lambda/bin/chromium-75.0.3765.0.br: �6��d�11�l��L���: not found
/home/connor/Desktop/serverless/node_modules/chrome-aws-lambda/bin/chromium-75.0.3765.0.br: 1: /home/connor/Desktop/serverless/node_modules/chrome-aws-lambda/bin/chromium-75.0.3765.0.br: cannot open c: No such file
/home/connor/Desktop/serverless/node_modules/chrome-aws-lambda/bin/chromium-75.0.3765.0.br: 1: /home/connor/Desktop/serverless/node_modules/chrome-aws-lambda/bin/chromium-75.0.3765.0.br: i��D-mPL�-X�R: not found
/home/connor/Desktop/serverless/node_modules/chrome-aws-lambda/bin/chromium-75.0.3765.0.br: 1: /home/connor/Desktop/serverless/node_modules/chrome-aws-lambda/bin/chromium-75.0.3765.0.br: U�#.: not found
/home/connor/Desktop/serverless/node_modules/chrome-aws-lambda/bin/chromium-75.0.3765.0.br: 2: /home/connor/Desktop/serverless/node_modules/chrome-aws-lambda/bin/chromium-75.0.3765.0.br: Syntax error: ")" unexpected
TROUBLESHOOTING: https://github.com/GoogleChrome/puppeteer/blob/master/docs/troubleshooting.md
at onClose (/home/connor/Desktop/serverless/node_modules/puppeteer-core/lib/Launcher.js:342:14)
at Interface.helper.addEventListener (/home/connor/Desktop/serverless/node_modules/puppeteer-core/lib/Launcher.js:331:50)
at Interface.emit (events.js:198:15)
at Interface.close (readline.js:394:8)
at Socket.onend (readline.js:172:10)
at Socket.emit (events.js:198:15)
at endReadableNT (_stream_readable.js:1139:12)
at processTicksAndRejections (internal/process/task_queues.js:81:17)
(node:17811) 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:17811) [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.
puppeteer-core does not include a chrome installation unlike the puppeteer package.
If you wish to use puppeteer in Lambda, try using a Lambda layer that already provides chrome for you such as https://github.com/RafalWilinski/serverless-puppeteer-layers.

Deprecation Warning Error with Blockchain

I'm trying to construct hyperledger fabric blockchain application. When I want to wake up the blockchain with npm:npm run env:restart, I get the following error:
UnhandledPromiseRejectionWarning: Unhandled promise rejection (rejection id: 2): Error: Errors found in script, stopping execution
(node:4432) [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.
How can i fix this?
my nvm version: 5.6.0
my nodejs version: 8.16.0
You are missing a catch block in a promise chain in your code.
Add it like this:
var p1 = new Promise(function(resolve, reject) {
throw new Error('Uh-oh!');
});
p1.catch(function(e) {
console.log(e); // "Uh-oh!"
});
For more information on Promises and catch block specifically, refer MDN.

(node:13606) UnhandledPromiseRejectionWarning: Unhandled promise rejection (rejection id: 1): [object Object] - Ionic Framework

I'm working with the Ionic Framework in its 3rd version, and when I run ionic cordova build --release android, I get this error :
(node:13791) UnhandledPromiseRejectionWarning: Unhandled promise rejection (rejection id: 1): [object Object]
(node:13791) [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.
Other threads about this didn't lead me anywhere. Please help
my first attempt would be to check my code for an unhandled promise rejection.
How can i dectect a unhandled promise rejection?
assuming we have a code like this:
asyncAction.then(success => {
// do stuff with the result of success
})
so if the asyncActions fails, there is an unhandled promise rejection because we never catch the rejection of the promise. To catch the rejection we need to do this:
asyncAction.then(success => {
// do stuff with the result of success
}, rejection => {
// handle action failed
})
I solved my problem downgrading cordova version to 7.1.0

Resources