Node.js/ webpack/ getaddrinfo looking for internet when not needed, why? - npm

I've got an issue with a machine that's supposed to be able to run offline.
I can pull the cable after my application is running, but during unplugged start I get the following error:
May 6 23:04:50 myco serve[4121]: (node:4121) UnhandledPromiseRejectionWarning: Error: getaddrinfo EAI_AGAIN registry.npmjs.org:443
May 6 23:04:50 myco serve[4121]: at Object._errnoException (util.js:1022:11)
May 6 23:04:50 myco serve[4121]: at errnoException (dns.js:55:15)
May 6 23:04:50 myco serve[4121]: at GetAddrInfoReqWrap.onlookup [as oncomplete] (dns.js:92:26)
May 6 23:04:50 myco serve[4121]: (node:4121) 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)
May 6 23:04:50 myco serve[4121]: (node:4121) [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.
It appears that dns.js is part of webpack/node-libs-browser but thats as far as I can seem to figure out.... I can't find GetAddrInfoReqWrap anywhere in my source tree, or getaddrinfo for that matter. Searching around there's a lot of info with people getting similar errors when deliberately trying to use npm, but thats not what I'm doing. I should have everything I need already on the machine.

Apparently this is a problem with serve.
Serve >6.5.3 apparently has an issue where it tries to contact the registry. Downgrade of serve to 6.5.3 solves this particular issue.
this is documented in https://github.com/zeit/serve/issues/348
not sure why serve would need to contact the registry.

noafterglow is right, but just for reference, rolling back to version 6.5.3 of serve can be accomplished with
npm install -g serve#6.5.3
Source: this post

I ran into exactly this error when trying to serve a VueJs app from a different VM from where the code was developed originally.
The file vue.config.js read :
module.exports = {
devServer: {
host: 'tstvm01',
port: 3030,
},
};
When served on the original machine the start up output is :
App running at:
- Local: http://tstvm01:3030/
- Network: http://tstvm01:3030/
Using the same settings on a VM tstvm07 got me a very similar error to the one the OP describes:
INFO Starting development server...
10% building modules 1/1 modules 0 activeevents.js:183
throw er; // Unhandled 'error' event
^
Error: getaddrinfo EAI_AGAIN
at Object._errnoException (util.js:1022:11)
at errnoException (dns.js:55:15)
at GetAddrInfoReqWrap.onlookup [as oncomplete] (dns.js:92:26)
If it ain't already obvious, changing vue.config.js to read ...
module.exports = {
devServer: {
host: 'tstvm07',
port: 3030,
},
};
... solved the problem.

Related

How to resolve "cannot pipe" issue with testcafe-hammerhead

When running tests, I'm getting the following error:
1 Unhandled promise rejection:
Error: Cannot pipe, not readable
at new NodeError (node:internal/errors:387:5)
at ServerResponse.pipe (node:_http_outgoing:1070:22)
at respondOnWebSocket (D:\e2e\0.0.157\node_modules\testcafe\node_modules\testcafe-hammerhead\lib\request-pipeline\websocket.js:56:9)
at Array.decideOnProcessingStrategy (D:\e2e\0.0.157\node_modules\testcafe\node_modules\testcafe-hammerhead\lib\request-pipeline\stages.js:77:48)
at run (D:\e2e\0.0.157\node_modules\testcafe\node_modules\testcafe-hammerhead\lib\request-pipeline\index.js:20:34)
at processTicksAndRejections (node:internal/process/task_queues:95:5)
Does anyone have a suggestion on how to resolve this?
See future updates related to this issue in this GitHub thread.

every command begin with npm has issue

Here is my problem,
I think I made mistake by adding proxy settings in a wrong way,
now every command begin with npm does not work.
here is a pic of the error:
λ npm config set registry "http://registry.npmjs.org/"
Error: Failed parsing JSON config key "proxy: "="'http://xxx.xx.xx.xx:8080'"
at parseField (E:\nodejs\node_modules\npm\lib\config\core.js:376:13)
at E:\nodejs\node_modules\npm\lib\config\core.js:330:24
at Array.forEach (<anonymous>)
at Conf.add (E:\nodejs\node_modules\npm\lib\config\core.js:328:23)
at ConfigChain.addString (E:\nodejs\node_modules\npm\node_modules\config-chain\index.js:244:8)
at Conf.<anonymous> (E:\nodejs\node_modules\npm\lib\config\core.js:316:10)
at E:\nodejs\node_modules\npm\node_modules\graceful-fs\graceful-fs.js:123:16
at FSReqCallback.readFileAfterClose [as oncomplete] (internal/fs/read_file_context.js:63:3)
Error: Failed parsing JSON config key "proxy: "="'http://xxx.xx.xx.xx:8080'"
at parseField (E:\nodejs\node_modules\npm\lib\config\core.js:376:13)
at E:\nodejs\node_modules\npm\lib\config\core.js:330:24
at Array.forEach (<anonymous>)
at Conf.add (E:\nodejs\node_modules\npm\lib\config\core.js:328:23)
at ConfigChain.addString (E:\nodejs\node_modules\npm\node_modules\config-chain\index.js:244:8)
at Conf.<anonymous> (E:\nodejs\node_modules\npm\lib\config\core.js:316:10)
at E:\nodejs\node_modules\npm\node_modules\graceful-fs\graceful-fs.js:123:16
at FSReqCallback.readFileAfterClose [as oncomplete] (internal/fs/read_file_context.js:63:3)
Assuming you set your proxy setting in a similar way to the registry setting you show: Delete the proxy line in your .npmrc file and try again. The .npmrc file can be found in the four places listed in the npm docs. In most cases, you'll find the one with the proxy entry in ~/.npmrc.

CypressError: `cy.visit()` failed trying to load: https://dev-eccc.env.xxxx.com/ via Gitlab CI job

I have setup a Gitlab ci/cd job to execute all cypress integration tests. I found that all tests are getting fail due to home URL is getting failed to load by cy.visit().
On my local machine it is working fine.
below is the complete Error trace:
CypressError: `cy.visit()` failed trying to load:
https://dev-eccc.env.ihsmarkit.com/
We attempted to make an http request to this URL but the request failed without a response.
We received this error at the network level:
> Error: getaddrinfo ENOTFOUND dev-eccc.env.ihsmarkit.com
Common situations why this would fail:
- you don't have internet access
- you forgot to run / boot your web server
- your web server isn't accessible
- you have weird network configuration settings on your computer
Because this error occurred during a `before all` hook we are skipping the remaining tests in the current suite: `Facility Register`
at http://localhost:45271/__cypress/runner/cypress_runner.js:156433:23
at visitFailedByErr (http://localhost:45271/__cypress/runner/cypress_runner.js:155794:12)
at http://localhost:45271/__cypress/runner/cypress_runner.js:156432:11
at tryCatcher (http://localhost:45271/__cypress/runner/cypress_runner.js:10130:23)
at Promise._settlePromiseFromHandler (http://localhost:45271/__cypress/runner/cypress_runner.js:8065:31)
at Promise._settlePromise (http://localhost:45271/__cypress/runner/cypress_runner.js:8122:18)
at Promise._settlePromise0 (http://localhost:45271/__cypress/runner/cypress_runner.js:8167:10)
at Promise._settlePromises (http://localhost:45271/__cypress/runner/cypress_runner.js:8243:18)
at _drainQueueStep (http://localhost:45271/__cypress/runner/cypress_runner.js:4837:12)
at _drainQueue (http://localhost:45271/__cypress/runner/cypress_runner.js:4830:9)
at Async.../../node_modules/bluebird/js/release/async.js.Async._drainQueues
(http://localhost:45271/__cypress/runner/cypress_runner.js:4846:5)
at Async.drainQueues (http://localhost:45271/__cypress/runner/cypress_runner.js:4716:14)
From Your Spec Code:
at Object.homepage_test (http://localhost:45271/__cypress/tests?p=cypress/integration/eccc-
app-ui-cypress/API/register_api.ts:71:8)
at Context.eval (http://localhost:45271/__cypress/tests?p=cypress/integration/eccc-app-ui-
cypress/API/register_api.ts:13:25)
From Node.js Internals:
Error: getaddrinfo ENOTFOUND dev-eccc.env.ihsmarkit.com
at GetAddrInfoReqWrap.onlookup [as oncomplete] (dns.js:60:26)

"Cannot read property 'upgrade' of undefined" when starting vue application

I have a project that's been running perfectly for a few months now, able to run npm run serve with no problem. I have to terminate and run the command again whenever I switch networks, but that has never been a problem and the server could always start again.
Until now - no matter what I do I can't get the server to start. I get this error:
npm run serve
> xbs#0.6.2 serve D:\workspace\[PROJECT]
> vue-cli-service serve
INFO Starting development server...
10% building 1/1 modules 0 active ERROR TypeError: Cannot read property 'upgrade' of undefined
TypeError: Cannot read property 'upgrade' of undefined
at Server.<anonymous> (D:\workspace\[PROJECT]\node_modules\webpack-dev-server\lib\Server.js:667:47)
at Array.forEach (<anonymous>)
at new Server (D:\workspace\[PROJECT]\node_modules\webpack-dev-server\lib\Server.js:666:22)
at serve (D:\workspace\[PROJECT]\node_modules\#vue\cli-service\lib\commands\serve.js:137:20)
at <anonymous>
at process._tickCallback (internal/process/next_tick.js:188:7)
at Function.Module.runMain (module.js:695:11)
at startup (bootstrap_node.js:191:16)
at bootstrap_node.js:612:3
The last time I got this message was when I forgot to set the .env files, but this is a previously working copy with all necessary files set, and no changes since the last working run.
I've even tried pulling a fresh copy of the repo, running npm i and setting all env files but it still fails.
npm run lint and npm run build can still work, only npm run serve.
Am I missing anything?
The problem was again with the .env files. My vue.config.js was trying to access a previously set environment variable that had since been removed.
Only strange thing was that there weren't any problems up til now?
I guess your devServer.proxy.target is empty!
You could set this configuration
For me it was that I forgot to create (or copy from another PC) the .env file after clone and try to run my project on another PC.
I also had this problem.
I used in the project process to get the backend address(for example):
devServer: {
proxy: {
'/api/back/*': {
target: process.env.VUE_APP_BACKEND_URL,
pathRewrite: {
'/api/back': '/api/back',
},
},
},
},
But there was no .evn file.
Just create .env file:
VUE_APP_BACKEND_URL= 0.0.0.0:2222 #example
Didn't notice the answer #Sergey.
I declared this environment variable in .env.dev, but the local build failed, and the same project ran without problems, so I created a new .env file and declared it in it
proxy: {
'/api': {
target: process.env.VUE_APP_PROXY,
changeOrigin: true,
pathRewrite: {
'^/api': ''
}
}
}

Unable to connect the Botium client with Google DialogFlow

Installed npm via mac terminal.
Installed botium client with npm command : npm install -g botium-cli
As directed in this tutorial :
Also have got allocated one DialogFlow instance and other details with project configuration as directed in the above linked tutorial.
Error I am getting while establishing the connection between botium client and DialogFlow :
Auth error:Error: error:0906D06C:PEM routines:PEM_read_bio:no start
line (node:25129) UnhandledPromiseRejectionWarning: Error: Cannot send
message to dialogflow container: { Error: 14 UNAVAILABLE: Getting
metadata from plugin failed with error: error:0906D06C:PEM
routines:PEM_read_bio:no start line
at Object.exports.createStatusError (/usr/local/lib/node_modules/botium-cli/node_modules/grpc/src/common.js:87:15)
at Object.onReceiveStatus (/usr/local/lib/node_modules/botium-cli/node_modules/grpc/src/client_interceptors.js:1188:28)
at InterceptingListener._callNext (/usr/local/lib/node_modules/botium-cli/node_modules/grpc/src/client_interceptors.js:564:42)
at InterceptingListener.onReceiveStatus (/usr/local/lib/node_modules/botium-cli/node_modules/grpc/src/client_interceptors.js:614:8)
at callback (/usr/local/lib/node_modules/botium-cli/node_modules/grpc/src/client_interceptors.js:841:24)
code: 14, metadata: Metadata { _internal_repr: {} }, details:
'Getting metadata from plugin failed with error: error:0906D06C:PEM
routines:PEM_read_bio:no start line' }
at /usr/local/lib/node_modules/botium-cli/node_modules/botium-connector-dialogflow/dist/botium-connector-dialogflow-cjs.js:222:14
(node:25129) 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: 12) (node:25129) [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.
If you need, there is also link to botium client
Can anyone help me here with the connection establishment and get going !
Same error was coming in my case when I was trying to connect botium to dialogue flow.
In my case DIALOGFLOW_PRIVATE_KEY was incorrect. Please check it, if it is starting with
------BEGIN PRIVATE KEY-----
and ends with
\n-----END PRIVATE KEY-----\n
This solved my issue:)