Problematic socket.parser.resume() error in node.js - javascript

This bug has been crashing my node.js server for the past one week. On average it seems to occur every 12 hours. Normally when an error occurs in node.js, node.js will tell you the line number and your source file that lead to the error. However, this error is so weird that it does not let me know where the error originates from in my source codes. I can't even find _http_server.js within the entire project and node modules. As such, I have been unable to pinpoint and eliminate the bug.
Without the stack trace module 'longjohn', I would get the following error message:
socket.parser.resume()
cannot read property resume of null (_http_server.js:442)
......
After I installed 'longjohn', I obtained the following error message:
TypeError: Cannot read property 'resume' of null
at socketOnDrain (_http_server.js:442:20)
at ServerResponse.updateOutgoingData [as _onPendingData] (_http_server.js:270:14)
at ServerResponse.OutgoingMessage._send (_http_outgoing.js:128:14)
at ServerResponse.OutgoingMessage.write (_http_outgoing.js:470:16)
at ReadStream.ondata (_stream_readable.js:525:20)
at emitOne (events.js:77:13)
at ReadStream.emit (events.js:169:7)
at readableAddChunk (_stream_readable.js:146:16)
at ReadStream.Readable.push (_stream_readable.js:110:10)
at onread (fs.js:1744:12)
at FSReqWrap.wrapper [as oncomplete] (fs.js:576:17)
---------------------------------------------
at ReadStream.Readable.on (_stream_readable.js:655:33)
at ReadStream.Readable.pipe (_stream_readable.js:522:7)
at SendStream.stream (C:\XXXX\node_modules\express\node_modules\send\lib\send.js:533:10)
at SendStream.send (C:\XXXX\node_modules\express\node_modules\send\lib\send.js:480:8)
at C:\XXXX\node_modules\express\node_modules\send\lib\send.js:392:10
at FSReqWrap.oncomplete (fs.js:82:15)
worker 1760 died
It is worthwhile mentioning that I am using socket.io. I am also using an external service called Global Counter that displays the number of online users. I am running setInterval() in one of the workers to remove expired records.
Could someone tell me the meaning of these error messages, how the error occurs, and how I should solve it?

according to https://github.com/nodejs/node/issues/3508, you may fix this problem after upgrading nodejs to v4.2.3+ or v5.1.1+

Related

Axios Timeout Error even if time is not expired

I have a Next js application which make requests to commerce js api, from getStaticProps function. I've tried to make the build several times, and sometimes it goes well, but sometimes it fails giving me the following error.
Error: timeout of 10000000ms exceeded at createError (/Users/nicolo/Desktop/shop-smb-for-schools/shop-smb-template-commercejs/node_modules/axios/lib/core/createError.js:16:15) at RedirectableRequest.handleRequestTimeout (/Users/nicolo/Desktop/shop-smb-for-schools/shop-smb-template-commercejs/node_modules/axios/lib/adapters/http.js:280:16) at Object.onceWrapper (node:events:627:26) at RedirectableRequest.emit (node:events:512:28) at eventHandlers.<computed> (/Users/nicolo/Desktop/shop-smb-for-schools/shop-smb-template-commercejs/node_modules/follow-redirects/index.js:13:24) at ClientRequest.emit (node:events:512:28) at TLSSocket.emitRequestTimeout (node:_http_client:841:9) at Object.onceWrapper (node:events:626:28) at TLSSocket.emit (node:events:524:35) at Socket._onTimeout (node:net:564:8)
I've tried to change the milliseconds settings from the config object when creating the instance of Commercejs, and even if the time is not expired it raises the error. Instead, if I try making the requests to the api, client side, they work properly even if they take some time.

HTTP 6369: SOCKET ERROR: read ECONNRESET - Node server connecting to Filemaker Data API

I have run into this error with my Node server when trying to access a Filemaker Server driven backend both locally and remotely.
HTTP 6369: SOCKET ERROR: read ECONNRESET Error: read ECONNRESET at TLSWrap.onStreamRead (internal/stream_base_commons.js:205:27)
After trying everything I can find, triple-checking my FMS settings and logs, restarting the server and the machine several times, I cannot figure out what exactly is going wrong and how to solve it.
I have seen some answers to similar questions here on SO, but for the most part they just suggest catching the error in the express route (has not been changed for months and was working fine before the error), which I have done but it just outputs a more verbose version of the main error above:
HTTP 6369: SOCKET ERROR: read ECONNRESET Error: read ECONNRESET
at TLSWrap.onStreamRead (internal/stream_base_commons.js:205:27)
at TLSSocket.Readable.on (_stream_readable.js:838:35)
at tickOnSocket (_http_client.js:691:10)
at onSocketNT (_http_client.js:744:5)
at processTicksAndRejections (internal/process/task_queues.js:84:21)
at ClientRequest.onSocket (_http_client.js:732:11)
at setRequestSocket (_http_agent.js:436:7)
at handleSocketCreation_Inner (_http_agent.js:429:7)
at oncreate (_http_agent.js:286:5)
at Agent.createSocket (_http_agent.js:291:5)
at Agent.addRequest (_http_agent.js:248:10)
at new ClientRequest (_http_client.js:296:16)
at Object.request (https.js:314:10)
at Request.start (/Users/******/Documents/*****/code/******/node_modules/request/request.js:751:32)
THE ERR : Error: read ECONNRESET
at TLSWrap.onStreamRead (internal/stream_base_commons.js:205:27)
at TLSSocket.Readable.on (_stream_readable.js:838:35)
at tickOnSocket (_http_client.js:691:10)
at onSocketNT (_http_client.js:744:5)
at processTicksAndRejections (internal/process/task_queues.js:84:21)
---------------------------------------------
at ClientRequest.onSocket (_http_client.js:732:11)
at setRequestSocket (_http_agent.js:436:7)
at handleSocketCreation_Inner (_http_agent.js:429:7)
at oncreate (_http_agent.js:286:5)
at Agent.createSocket (_http_agent.js:291:5)
at Agent.addRequest (_http_agent.js:248:10)
at new ClientRequest (_http_client.js:296:16)
at Object.request (https.js:314:10)
at Request.start (/Users/********/Documents/*******/code/******/node_modules/request/request.js:751:32) {
errno: 'ECONNRESET',
code: 'ECONNRESET',
syscall:'read'
}
Also, my Node API in general had already been operating more or less seamlessly for several months of development before this problem arose. One thing was that changed on my machine was my company adding ScaleFusion device management software. I mentioned before the install that it could cause problems with the Node server API calls and the error only happened after ScaleFusion was added. Maybe it is possible the software is causing this problem?
Have been trying to find a fix for a couple of days now but running out of leads on it. If anyone can help out I'd really appreciate it. Thanks in advance for any suggestions.

Getting this socket error in discord.js and can't debug it [duplicate]

This error randomly appears When leaving my discord bot online for too long, around 3-4 hours but sometimes the error occurs sooner and sometimes later. It's really bothering me.
events.js:188
throw err;
^
Error: Unhandled "error" event. ([object Object])
at Client.emit (events.js:186:19)
at WebSocketConnection.onError (D:\BasementMonster\node_modules\discord.js\src\client\websocket\WebSocketConnection.js:374:17)
at WebSocket.onError (D:\BasementMonster\node_modules\ws\lib\event-target.js:128:16)
at emitOne (events.js:116:13)
at WebSocket.emit (events.js:211:7)
at _receiver.cleanup (D:\BasementMonster\node_modules\ws\lib\websocket.js:211:14)
at Receiver.cleanup (D:\BasementMonster\node_modules\ws\lib\receiver.js:557:13)
at WebSocket.finalize (D:\BasementMonster\node_modules\ws\lib\websocket.js:206:20)
at emitOne (events.js:116:13)
at TLSSocket.emit (events.js:211:7)
at emitErrorNT (internal/streams/destroy.js:64:8)
at _combinedTickCallback (internal/process/next_tick.js:138:11)
at process._tickCallback (internal/process/next_tick.js:180:9)
I wrestled with this problem for a while in my own code. The main problem is that the trace is completely unhelpful, and that the error occurs so infrequently as to make "run it in the terminal and wait" a futile task. Eventually, I was able to figure out that the Discord.js client itself was throwing an error -- this wasn't mentioned in any of the documentation I read, so I had no handler for it -- and since this oopsie happens in the Discord.js package itself, there was no line in my code for it to point to in the trace.
What needs to exist in the code somewhere is something along the lines of
client.on('error', (err) => {
console.log(err.message)
});
This is adjusted, of course, for whatever your Client object is, and whatever you want the error handling to be.
This specific trace, as far as I can tell, comes from losing Internet connection, which is something I want to have a record of, so instead of console.log() I called my own custom function that writes the event out to a logfile with a timestamp.
Testing this by running an instance of the bot and killing my Internet connection revealed that not only did the logging function work, but that Discord.js automatically restored the bot's session after it came back. (Your mileage may vary.)
You need to add an error handling event, like this:client.on('error', console.error);

How can I make JavaScript exceptions more informative?

A very frustrating thing about JavaScript is that if it fails on an external module, it doesn't tell you the line of your code that initiated the path.
For example:
Unhandled rejection RequestError: Error: socket hang up
at new RequestError (/../node_modules/request-promise/lib/errors.js:11:15)
at Request.RP$callback [as _callback] (/../node_modules/request-promise/lib/rp.js:60:32)
at self.callback (/../node_modules/request/request.js:199:22)
at Request.emit (events.js:95:17)
at Request.onRequestError (/../node_modules/request/request.js:821:8)
at ClientRequest.emit (events.js:95:17)
at Socket.socketOnEnd (http.js:1569:9)
at Socket.g (events.js:180:16)
at Socket.emit (events.js:117:20)
at _stream_readable.js:944:16
at process._tickDomainCallback (node.js:492:13)
In what reality is this stack trace useful? Is there any way to get it to print the last "non node_module" call that resulted in the exception?
There are several node modules providing an "async stacktrace". They seem to provide a similar functionality to the Async checkbox in the Chrome developer tools (under "Sources"). I have never actually worked with any of them, and I don't think they're necessarily meant for production systems, but they may well be useful for a development environment.
A quick google search shows you a number of possible modules (e.g. async-stacktrace).

Mongodb events.js:85

I am working on this project since long. I am facing some problem which I am unable to solve after trying really hard. I would really appreciate if you guys can help me. I am trying to connect to mongodb database using node.js but whenever I start server I get following error. And I have no idea how to solve that error.
{ [Error: Cannot find module '../build/Release/bson'] code: 'MODULE_NOT_FOUND' }
js-bson: Failed to load c++ bson extension, using pure JS version
The magic happens on port 8080
Connected correctly to server
events.js:85
throw er; // Unhandled 'error' event
^
Error: failed to connect to [undefined:27017]
at null.<anonymous> (C:\Users\Admin\Desktop\Apps\linked-up 0.0.1\easy-node-authentication-master\node_modules\mongoose\node_modules\mongodb\lib\mongodb\connection\server.js:556:74)
at emit (events.js:118:17)
at null.<anonymous> (C:\Users\Admin\Desktop\Apps\linked-up 0.0.1\easy-node-authentication-master\node_modules\mongoose\node_modules\mongodb\lib\mongodb\connection\connection_pool.js:156:15)
at emit (events.js:110:17)
at Socket.<anonymous> (C:\Users\Admin\Desktop\Apps\linked-up 0.0.1\easy-node-authentication-master\node_modules\mongoose\node_modules\mongodb\lib\mongodb\connection\connection.js:534:10)
at Socket.emit (events.js:107:17)
at net.js:950:16
at process._tickCallback (node.js:355:11)
Thank you for your time and consideration
Are you sure you are up and running mongodb locally in the system ?
To map local path to mongodb try the following command
[location of mongodb]/bin/ mongod --dbpath "specify location of database"
Do you write you code like below?
mongoose.connect(configDB.url); // connect to database
I guess you did't set your configDB.url .
set it with your db url like 'localhost:27017/myDatabase'

Categories

Resources