What does "MongoError: Error: corrupt bson message" mean? - node.js

I'm suddenly running into this issue with MongoDB. We are running a NodeJS app with npm mongoose (v4.1.3), npm mongodb (v2.0.42), and MongoDB (v3.0.10). We are running a replica set with a primary and one secondary. This coincides with a recently deployed new version of our app in production, but we haven't changed versions of MongoDB or mongoose recently, so I'm not sure why this is suddenly happening.
I can't find any useful information on what causes this error, or what it means. After the error occurs, our mongoose connection locks up and all interaction with the database becomes a black hole of unresponsiveness. Rebooting the app is the only way to restore database connectivity.
I'm interested in what this error message means and how to prevent it from happening.
The error has happened while interacting with 2 different collections, with 2 different queries. The queries are very basic.
MongoError: Error: corrupt bson message
at .messageHandler (../node_modules/mongoose/node_modules/mongodb/node_modules/mongodb-core/lib/topologies/server.js:245:29)
at Socket.<anonymous> (../node_modules/mongoose/node_modules/mongodb/node_modules/mongodb-core/lib/connection/connection.js:181:18)
at emitOne (events.js:96:13)
at Socket.emit (events.js:188:7)
at readableAddChunk (_stream_readable.js:177:18)
at Socket.Readable.push (_stream_readable.js:135:10)
at TCP.onread (net.js:542:20)

Related

Why am I getting a rate limiting error on post requests?

Whenever I send a post request, I'm getting the following error. I couldn't track down where it is coming from.
SentryError: HTTP Error (429): Creation of this event was denied due to rate limiting
at new SentryError (/home/bwsuser/bws-verwaltung/node_modules/#sentry/core/dist/error.js:9:28)
at ClientRequest.<anonymous> (/home/bwsuser/bws-verwaltung/node_modules/#sentry/node/dist/transports/base.js:46:44)
at Object.onceWrapper (events.js:315:30)
at emitOne (events.js:116:13)
at ClientRequest.emit (events.js:211:7)
at HTTPParser.parserOnIncomingClient (_http_client.js:543:21)
at HTTPParser.parserOnHeadersComplete (_http_common.js:112:17)
at TLSSocket.socketOnData (_http_client.js:440:20)
at emitOne (events.js:116:13)
at TLSSocket.emit (events.js:211:7)
at addChunk (_stream_readable.js:263:12)
at readableAddChunk (_stream_readable.js:250:11)
at TLSSocket.Readable.push (_stream_readable.js:208:10)
at TLSWrap.onread (net.js:597:20)
anyone has any idea what might be causing that? or at least where to start looking.
I ran out of ideas here :/
anyone has any idea what might be causing that? or at least where to start looking. I ran out of ideas here :/
Yes, certainly, you need to look here at Quota Management | Sentry Documentation. It mostly happens when you run an app from a local dev server. Here's the summary right from the doc ...
Sentry completes a thorough evaluation of each event to determine if it counts toward your quota, as outlined in this overview. Detailed documentation for each evaluation is linked throughout. Before completing any of these evaluations, Sentry confirms that each event includes a valid DSN and project as well as whether the event can be parsed. In addition, for error events, Sentry validates that the event contains valid fingerprint information. If any of these items are missing or incorrect, the event is rejected.
Another hint, try to disable all your browser extensions and check if that call is gone. I just figure out it is called by a chrome extension for me.
Hope helps

Connection to Mongodb Atlas cluster is closing unexpectedly

I am getting mongo error ie 'connection to MongoDB closed' for every other database request that I am making, I looked it up and the solutions were
whitelisting IP - added 0.0.0.0/0 to allowed IP,
setting up the URI correctly,
Checking connection - was able to connect from Studio 3t application,
The error Log says:
MongoError: connection 72 to cluster0-shard-00-01-****.mongodb.net:27017 closed
at Function.MongoError.create (/**/node_modules/mongodb-core/lib/error.js:29:11)
at TLSSocket.<anonymous> (/**/node_modules/mongodb-core/lib/connection/connection.js:214:22)
at Object.onceWrapper (events.js:285:13)
at TLSSocket.emit (events.js:202:15)
at TLSSocket.EventEmitter.emit (domain.js:446:20)
at _handle.close (net.js:611:12)
at Socket.done (_tls_wrap.js:412:7)
at Object.onceWrapper (events.js:285:13)
at Socket.emit (events.js:197:13)
at Socket.EventEmitter.emit (domain.js:446:20)
at TCP._handle.close (net.js:611:12)
I have tried everything with no results, If someone can help me out for which direction to look into or anyone who has faced it and resolved it who can guide me, it would be much appreciated.
Go to your cluster network access and add again your IP address in the IP Whitelist. I am using wi-fi and my id change periodically.

Application Insights: CorrelationIdManager error in node js

I am using application insights on my node js application and I keep on getting this error. Can you please help me
ApplicationInsights:CorrelationIdManager [ { Error: unable to verify the first certificate
at TLSSocket.<anonymous> (_tls_wrap.js:1105:38)
at ZoneDelegate.invokeTask (C:\src\xyz\xyz\xyz\node_modules\zone.js\dist\zone-node.js:275:35)
at Zone.runTask (C:\src\xyz\xyz\xyz\node_modules\zone.js\dist\zone-node.js:151:47)
at TLSSocket.ZoneTask.invoke (C:\src\xyz\xyz\xyz\node_modules\zone.js\dist\zone-node.js:345:33)
at emitNone (events.js:106:13)
at TLSSocket.emit (events.js:208:7)
at TLSSocket._finishInit (_tls_wrap.js:639:8)
at TLSWrap.ssl.onhandshakedone (_tls_wrap.js:469:38) code: 'UNABLE_TO_VERIFY_LEAF_SIGNATURE' } ]
You're seeing this error because of transient problems on the Application Insights backend, but the error should not be fatal and your app should continue working as expected (albeit with this message being printed).
In the default configuration of the Application Insights SDK for Node.js, communication with the backend is retried - so you should be able to ignore this error and still see telemetry show up in the Azure Portal.
If you've changed the defaults, the setting you'll want to make sure to set is .setUseDiskRetryCaching(true) For example:
appInsights.setup("key")
.setUseDiskRetryCaching(true)
.start()
If you want to suppress messages like this from the SDK you can disable internal logging: (Be aware you'll be suppressing other errors potentially as well)
appInsights.setup("key")
.setUseDiskRetryCaching(true)
.setInternalLogging(false, false)
.start()
If you're curious about the history of this issue, and why it spontaneously occurs, there's a long-running issue on GitHub here: https://github.com/Microsoft/ApplicationInsights-node.js/issues/180

429 Too Many Requests Error While Running Mocha Test - NodeJS / Swagger API

I used swagger (swagger.io) to built my app's API and everything works fine in production environment. However, when I ran some mocha tests on these APIs, I keep getting this error regarding status code 429 Too Many Requests:
Unhandled rejection Error: Too Many Requests
at Request.callback (..../node_modules/superagent/lib/node/index.js:698:17)
at IncomingMessage.<anonymous> (..../node_modules/superagent/lib/node/index.js:922:12)
at emitNone (events.js:91:20)
at IncomingMessage.emit (events.js:185:7)
at endReadableNT (_stream_readable.js:926:12)
at _combinedTickCallback (internal/process/next_tick.js:74:11)
at process._tickDomainCallback (internal/process/next_tick.js:122:9)
Usually this error happens after I ran the mocha test twice in a row (ie start throwing this error from the third time onwards). I suspected I was overloading my localhost server, but the error persisted even after I closed and reopened the server.
Would be super grateful if someone could point me towards the right direction to solve this problem.

Does sails.js support database views?

I would like to migrate my application to sails.js. But, I use database views on my PostgreSQL database for some functions.
I try to make a model for this view. But, it causes an ORM error when I perform sails lift.
error: A hook (`orm`) failed to load!
error: error: relation "homeview" already exists
at Connection.parseE (/home/onlinemad/git/appname2/node_modules/sails-postgresql/node_modules/pg/lib/connection.js:561:11)
at Connection.parseMessage (/home/onlinemad/git/appname2/node_modules/sails-postgresql/node_modules/pg/lib/connection.js:390:17)
at null.<anonymous> (/home/onlinemad/git/appname2/node_modules/sails-postgresql/node_modules/pg/lib/connection.js:92:20)
at Socket.EventEmitter.emit (events.js:95:17)
at Socket.<anonymous> (_stream_readable.js:746:14)
at Socket.EventEmitter.emit (events.js:92:17)
at emitReadable_ (_stream_readable.js:408:10)
at emitReadable (_stream_readable.js:404:5)
at readableAddChunk (_stream_readable.js:165:9)
at Socket.Readable.push (_stream_readable.js:127:10)
Does sails.js support database views, and if so do they require special configuration?
You can use a database view with your Sails app by setting the migrate property to safe in the model that uses the view:
module.exports = {
migrate: 'safe',
attributes: {
...
}
}
This will restrict Sails from performing migrations on the view, meaning that if you add new attributes to the model, they will not be automagically added to the database view. You'll have to keep your Sails model and your database view in sync manually.

Resources