Gulp crash with an HPE_INVALID_CONSTANT error on first XHR request - node.js

I'm developing an AngularJS 1.7.x application (started 3 years ago), and when I started Gulp was the tool to use.
Yesterday, when I resume my work on my app, I suddenly get a crash on the first XHR request.
So I run "gulp serve", it opens chrome with the login page, everything is loading correctly, and then, I click the login button, which issue a REST call to my PHP Backend (served by Apache/2.4.37 (Unix) PHP/7.2.14)
The package.json of my project didn't changed in quite some time.
I've recently updated npm (6.9.0) & node (8.11.1), but it's not that recent.
[12:14:13] Starting 'serve'...
[HPM] Proxy created: /rest -> http://localhost/
[12:14:13] Finished 'serve' after 49 ms
[BrowserSync SPA] Running...
[Browsersync] Access URLs:
--------------------------------------
Local: http://localhost:3000/
External: http://192.168.1.21:3000/
--------------------------------------
UI: http://localhost:3001
UI External: http://localhost:3001
--------------------------------------
[Browsersync] Serving files from: .tmp/serve
[Browsersync] Serving files from: src
[HPM] Error occurred while trying to proxy request /rest/authenticate from localhost:3000 to http://localhost/ (HPE_INVALID_CONSTANT) (https://nodejs.org/api/errors.html#errors_common_system_errors)
events.js:183
throw er; // Unhandled 'error' event
^
Error: write after end
at write_ (_http_outgoing.js:622:15)
at ServerResponse.write (_http_outgoing.js:617:10)
at IncomingMessage.ondata (_stream_readable.js:639:20)
at emitOne (events.js:116:13)
at IncomingMessage.emit (events.js:211:7)
at IncomingMessage.Readable.read (_stream_readable.js:475:10)
at flow (_stream_readable.js:846:34)
at resume_ (_stream_readable.js:828:3)
at _combinedTickCallback (internal/process/next_tick.js:138:11)
at process._tickCallback (internal/process/next_tick.js:180:9)

In my php Backend, my configuration file was giving an empty "ReCaptcha" secret, which end up producing this crash on gulp/proxy...
Can't understand why the error thrown by ReCaptcha can mess up the proxy so much...

Related

Decentraland project not starting properly

I am trying to run 'dcl start' command from the terminal. The Decentraland Preview webpage opens and terminal says 'Acquring comms connection'. But after that it gives the error below:
Oops, it seems the catalyst isn't working well. [HPM] Error occurred while proxying request 127.0.0.1:8000/lambdas/collections/wearables?collectionId=urn:decentraland:off-chain:base-avatars to https://peer.decentraland.org/ [ECONNRESET] (https://nodejs.org/api/errors.html#errors_common_system_errors) Oops, it seems the catalyst isn't working well. [HPM] Error occurred while proxying request 127.0.0.1:8000/lambdas/collections/wearables?wearableId=urn:decentraland:off-chain:base-avatars:elegant_striped_shirt&wearableId=urn:decentraland:off-chain:base-avatars:elegant_blue_trousers&wearableId=urn:decentraland:off-chain:base-avatars:f_m_sandals&wearableId=urn:decentraland:off-chain:base-avatars:modern_hair&wearableId=urn:decentraland:off-chain:base-avatars:f_mouth_04 to https://peer.decentraland.org/ [ECONNRESET] (https://nodejs.org/api/errors.html#errors_common_system_errors) [HPM] ECONNRESET: Error: socket hang up at connResetException (node:internal/errors:704:14) at TLSSocket.socketOnEnd (node:_http_client:505:23) at TLSSocket.emit (node:events:525:35) at endReadableNT (node:internal/streams/readable:1358:12) at processTicksAndRejections (node:internal/process/task_queues:83:21) { code: 'ECONNRESET' }
What could cause this error ?

node error when calling "yarn start" in an app created by create-react-app

I recently created a new project with create-react-app, installed all newest packages for an old create-react-app project (which was using react-scripts 3.4.1, and the new project is using 5.0.0) and copied the old code and asset files over. To my puzzlement, the new project throws an error whenever I call "yarn start"
Starting the development server...
node:events:498
throw er; // Unhandled 'error' event
^
Error: read ECONNRESET
at TLSWrap.onStreamRead (node:internal/stream_base_commons:217:20)
Emitted 'error' event on ClientRequest instance at:
at TLSSocket.socketErrorListener (node:_http_client:442:9)
at TLSSocket.emit (node:events:520:28)
at TLSSocket.emit (node:domain:475:12)
at emitErrorNT (node:internal/streams/destroy:164:8)
at emitErrorCloseNT (node:internal/streams/destroy:129:3)
at processTicksAndRejections (node:internal/process/task_queues:83:21) {
errno: -54,
code: 'ECONNRESET',
syscall: 'read'
}
Node.js v17.4.0
error Command failed with exit code 1.
info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.
For what it's worth, the old project doesn't throw an error despite that the src code is the same. The only difference is the packages.
I googled around and followed various advice, including this one: https://medium.com/#premal.katigar/how-to-fix-throw-er-unhandled-error-event-30172323a973. All to no avail.
There are a couple of clues that could be useful:
I use an antd landing page, which is basically a bunch of .jsx and .less files that constructs a page. If I replace that landing page code with some simple jsx component, e.g. something that simply returns an h1 tag, then there is no longer this node error. Yarn start would start the project fine.
The only differences between the old project that starts fine even with the aforementioned antd landing page, and the new one that throws the above error are that 1) the new project contains all the newest versions of the required packages, since I used "yarn install" for all the required packages 2) since I'm using the newest version of antd, instead of using "customize-cra", "react-app-wired", "babel-plugin-import" and "less-loader", I was simply using "craco-less". So the old project's "yarn start" actually called "react-app-rewired start" and the new one actually called "craco start".
I also tried downgrading node version from 17 to 16, and the error remained.
Any clue what might be the issue?

Fail to start browser sync

I'm new to these things. I just started to learn web development through a free course in Coursera, and I'm having trouble in setting up the development environment.
That's what I did: installed Sublime Text 3, git and node.js. Created a repository on git, a web page with Sublime and committed it to git.
Now I'm trying to start browser sync but I'm getting this:
$ browser-sync start --server --directory --files "*"
[BS] Access URLs:
-------------------------------------
Local: http: //localhost:3000
External: http: //192.168.0.13:3000
-------------------------------------
UI: http: //localhost:3001
UI External: http: //192.168.0.13:3001
-------------------------------------
[BS] Serving files from: ./
[BS] Watching files...
events.js:141
throw er; // Unhandled 'error' event
^
Error: spawn cmd ENOENT
at exports._errnoException (util.js:870:11)
at Process.ChildProcess._handle.onexit (internal/child_process.js:178:32)
at onErrorNT (internal/child_process.js:344:16)
at nextTickCallbackWith2Args (node.js:442:9)
at process._tickCallback (node.js:356:17)
I searched a lot but couldn't find a solution.
Browser isn't synchronizing.
One of the mentors of the course helped me with the solution.
The cause of this error was that it was missing the C:\Windows\System32\ variable in the System Variables. I added it and it solved my problem.

Unable to run (gulp serve) Google Polymer Starter Kit v1.1.0 on Windows

I need help please!
I have been able to effortlessly install and run all previous versions of the PSK. I have spent hours now trying to get 1.1.0 to run in my environment. I have done everything I can think of. From googling the error to reviewing all current issues with this version here. Any of the suggested fixes dont work for me.
I have made no code changes and I am running CMD as the Admin.
When I grab a fresh copy of the repository and do the NPM & Bower installs, then run "gulp serve" I get the following error no matter what:
C:\FrontEnd\polymer-starter-kit>gulp serve
[09:45:33] Using gulpfile C:\FrontEnd\polymer-starter-kit\gulpfile.js
[09:45:33] Starting 'styles'...
[09:45:33] Starting 'elements'...
[09:45:33] Starting 'images'...
[09:45:33] Finished 'elements' after 249 ms
[09:45:33] styles all files 98 B
[09:45:33] Finished 'styles' after 590 ms
[09:45:34] images all files 35.41 kB
[09:45:34] Finished 'images' after 357 ms
[09:45:34] Starting 'serve'...
[09:45:34] Finished 'serve' after 73 ms
[PSK] Access URLs:
------------------------------------
Local: http://localhost:5000
External: http://xxx.xxx.x.x:5000
------------------------------------
UI: http://localhost:3001
UI External: http://xxx.xxx.x.x:3001
------------------------------------
[PSK] Serving files from: .tmp
[PSK] Serving files from: app
events.js:141
throw er; // Unhandled 'error' event
^
Error: spawn cmd ENOENT
at exports._errnoException (util.js:837:11)
at Process.ChildProcess._handle.onexit (internal/child_process.js:178:32)
at onErrorNT (internal/child_process.js:344:16)
at doNTCallback2 (node.js:429:9)
at process._tickCallback (node.js:343:17)
My Environment:
All Required Prerequisites
Windows 10
Node.js v4.1.1
NPM v3.3.4
Bower v1.5.3
I am also not sure how to get a more detailed stack trace.
What should I do?
Thanks for the help!
It turns out I needed to add C:\Windows\System32 to my PATH vars. So strange. When I did that everything work like a charm.

Mongoose Can't Connect Without Internet

I have my MongoDB server running on localhost:27017, and while I can usually run my Node.js app fine, when I disconnect from the internet Mongoose throws the error
Error: failed to connect to [localhost:27017]
Note that I can still connect to the MongoDB server from the Mongo shell client. Also, if I start up my app first and then lose internet connection, my app can access the database fine offline. So why can't it start up without internet?
EDIT: here is the error in full
events.js:85
throw er; // Unhandled 'error' event
^
Error: failed to connect to [localhost:27017]
at null.<anonymous> (<My App>\node_modules\mongoose\
node_modules\mongodb\lib\mongodb\connection\server.js:555:74)
at emit (events.js:118:17)
at null.<anonymous> (<My App>\node_modules\mongoose\
node_modules\mongodb\lib\mongodb\connection\connection_pool.js:156:15)
at emit (events.js:110:17)
at Socket.<anonymous> (<My App>\node_modules\mongoos
e\node_modules\mongodb\lib\mongodb\connection\connection.js:534:10)
at Socket.emit (events.js:107:17)
at net.js:923:16
at process._tickCallback (node.js:355:11)
[nodemon] app crashed - waiting for file changes before starting...
Edit: wording
Use 127.0.0.1 instead of localhost. By turning off your wifi interface the OS is no longer able to resolve localhost.
Consider node-offline-localhost.
Add the following before the breaking code:
require('node-offline-localhost').always();
And it just works (hopefully), at least until RFC 3493 gets fixed.
Full disclosure: I authored this package to streamline https in my dev environment when offline.

Resources