Trying to load webpage using OpenUrl package in nodejs using setInterval - javascript

I am new to NodeJS, I have a microservice running which I want to open a webpage without a browser, to make client side api requests every 20 seconds. I am attempting to use the package openurl
const openPage = require("openurl");
function openUpPage(url){
openPage.open(url);
}
setInterval(function() { openUpPage("myURl") }, 20000);
However I now keep getting the error:
events.js:183
throw er; // Unhandled 'error' event
Error: spawn xdg-open ENOENT
at _errnoException (util.js:1022:11)
at Process.ChildProcess._handle.onexit (
internal/child_process.js:190:19)
at onErrorNT (internal/child_process.js:372:16)
at _combinedTickCallback (internal/process/next_tick.js:138:11)
at process._tickCallback (internal/process/next_tick.js:180:9)

Related

error Failed to run jetifier. while going to run react native app on mobile

I'm unable to run my react native app on my physical device. It was working fine todays morning also.
error Failed to run jetifier.
Error: Command failed: C:\Users\Ashish Nath\Desktop\react native\AwesomeProject\node_modules#react-native-community\cli-platform-android\node_modules\jetifier\bin\jetify
at makeError (C:\Users\Ashish Nath\Desktop\react native\AwesomeProject\node_modules#react-native-community\cli-platform-android\node_modules\execa\index.js:174:9)
at C:\Users\Ashish Nath\Desktop\react native\AwesomeProject\node_modules#react-native-community\cli-platform-android\node_modules\execa\index.js:278:16
at processTicksAndRejections (node:internal/process/task_queues:96:5)
at async Object.runAndroid [as func] (C:\Users\Ashish Nath\Desktop\react native\AwesomeProject\node_modules#react-native-community\cli-platform-android\build\commands\runAndroid\index.js:104:7)
at async Command.handleAction (C:\Users\Ashish Nath\Desktop\react native\AwesomeProject\node_modules#react-native-community\cli\build\index.js:186:9)
info Run CLI with --verbose flag for more details.

postgres - password authentication fails from windows docker container

I'm trying to do a simple getting-started exercise using dockerized postgres + a nodejs connction on windows. I ran:
$ docker run -d --name dev-postgres -e POSTGRES_PASSWORD=testpw -p 5432:5432 postgres
701682e86a66f7efb81af2ebb3a92d442c52742d2cd3d008de690bf1fa73d896
And then am using the following snippet from the pg library:
const { Client } = require("pg");
const connectionString = "postgresql://postgres:testpw#localhost:5432/postgres";
const client = new Client({
connectionString,
});
client.connect();
client.query("SELECT $1::text as message", ["Hello world!"], (err, res) => {
console.log(err ? err.stack : res.rows[0].message); // Hello World!
client.end();
});
But it crashes with:
(node:8764) UnhandledPromiseRejectionWarning: error: password authentication failed for user "postgres"
at Parser.parseErrorMessage (C:\Users\MikeSolomon\devel\user-flow-processor\vidgen\node_modules\pg-protocol\dist\parser.js:278:15)
at Parser.handlePacket (C:\Users\MikeSolomon\devel\user-flow-processor\vidgen\node_modules\pg-protocol\dist\parser.js:126:29)
at Parser.parse (C:\Users\MikeSolomon\devel\user-flow-processor\vidgen\node_modules\pg-protocol\dist\parser.js:39:38)
at Socket.<anonymous> (C:\Users\MikeSolomon\devel\user-flow-processor\vidgen\node_modules\pg-protocol\dist\index.js:10:42)
at Socket.emit (events.js:310:20)
at addChunk (_stream_readable.js:286:12)
at readableAddChunk (_stream_readable.js:268:9)
at Socket.Readable.push (_stream_readable.js:209:10)
at TCP.onStreamRead (internal/stream_base_commons.js:186:23)
(node:8764) 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:8764) [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.
Error: Connection terminated unexpectedly
at Connection.<anonymous> (C:\Users\MikeSolomon\devel\user-flow-processor\vidgen\node_modules\pg\lib\client.js:132:73)
at Object.onceWrapper (events.js:416:28)
at Connection.emit (events.js:310:20)
at Socket.<anonymous> (C:\Users\MikeSolomon\devel\user-flow-processor\vidgen\node_modules\pg\lib\connection.js:58:12)
at Socket.emit (events.js:310:20)
at TCP.<anonymous> (net.js:672:12)
I've tried several different to get the config working, but none has panned out yet. Can anybody spot what I'm doing wrong? Is this a Windows issue? I checked the docker container using exec bash and can use psql without any issues from within the container. Thanks for your help!
Word to the wise - it turns out that, on Windows, if you have another instance of postgres running on 5432, this will fail in this way. The solution for me was to simply stop that instance. Unfortunately, as it was a background process that started on system start, it took me a while to figure out it was there.

error trying to implement react-native maps

I'm trying to integrate google maps into my react native app I keep getting this error.
events.js:183
throw er; // Unhandled 'error' event
^
Error: listen EADDRINUSE :::8081
at Server.setupListenHandle [as _listen2] (net.js:1360:14)
at listenInCluster (net.js:1401:12)
at Server.listen (net.js:1485:7)
at C:\projects\test\node_modules\metro\src\index.js:205:18
at new Promise (<anonymous>)
at Object.<anonymous> (C:\projects\test\node_modules\metro\src\index.js:204:12)
at Generator.next (<anonymous>)
at step (C:\projects\testnode_modules\metro\src\index.js:58:30)
at C:\projects\test\node_modules\metro\src\index.js:69:15
at <anonymous>
Assuming you are using Linux.
It seems that your process is locked. In a terminal type the following:
ps -aux | grep '8081
copy the process ID
type in the terminal
sudo kill -9 ID-HERE replace ID-HERE with the process ID.
Restart the application.
If you are using Windows
type Ctrl+SHIFT+Esc to open the process window
Look for your process
Right click on the process and choose end process
Restart the application

Error: There are some read requests waitng on finished stream

I have working in selenium test cases. below is my code
browser.load('/sample/demo.html');
browser.sleep(2000);
element(By.id('upload')).sendKeys("D:\\files\\document.docx");
browser.compareScreen(element(By.tagName('body')), 'image1');
By adding the above code, i can get the files properly. But i have facing the below error
Error: There are some read requests waitng on finished stream
Stack:
Error: There are some read requests waitng on finished stream
at module.exports.ChunkStream._end (node_modules\pngjs-image\node_modules\pngjs\lib\chunkstream.js:100:7)
at module.exports.ChunkStream.end (node_modules\pngjs-image\node_modules\pngjs\lib\chunkstream.js:86:10)
at Inflate.onend (_stream_readable.js:595:10)
at Object.onceWrapper (events.js:313:30)
at emitNone (events.js:111:20)
at Inflate.emit (events.js:208:7)
at endReadableNT (_stream_readable.js:1056:12)
at _combinedTickCallback (internal/process/next_tick.js:138:11)
at process._tickCallback (internal/process/next_tick.js:180:9)
Message:
Error: Timeout - Async callback was not invoked within timeout specified by jasmine.DEFAULT_TIMEOUT_INTERVAL
I have tried to update the pngjs version to 3.3 above using npm install pngjs --save but still same issue occurs.
Any one can suggest how to resolve this error. I couldn't get the details about this issue properly.

Node JS Random events.js:72 throw er;

I know this has been raised a lot of times on here, other threads suggest that the port is already in use and that's why it crashes.
In this case, it's been running for days, using that port and will randomly crash with this error. It's had the port locked for days with no problems and is literally the only daemon on the server.
We're running on port 3000.
events.js:72
throw er; // Unhandled 'error' event
^
Error: getaddrinfo ESRCH
at errnoException (dns.js:37:11)
at Object.onanswer [as oncomplete] (dns.js:124:16)
Any help would be grateful

Categories