Stopped receiving events from ES after Receiving Unhandled promise rejection error

I use Nest,js with https://github.com/RemoteMetering/geteventstore-promise for an e-commerce site. It had been working fine for the first couple of months and recently up until now we’ve got strange behaviour from ES. Sometimes we see an error that would stop us from receiving events from ES, which I will show more below, or connection dropped then we have to restart the system to get it working, but soon it would happen again.

The first few times it happened at the time of creating order, we decided to reduce data in the stream and we saw that we have not got the error there anymore. Now we are facing the issue with payment. After we have got the payment confirmed, we would create maximum of 5 events of similar data as below:

https://jsoneditoronline.org/#left=cloud.9fb5ca86cddf402eb1b14e132e19e650

The error I received is:

(node:18) 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: 7)
(node:18) UnhandledPromiseRejectionWarning: TypeError: Cannot read property ‘error’ of undefined
at VolatileSubscriptionOperation. (/usr/src/app/dist/src/event-store/event-store.js:101:25)
at Generator.next ()
at /usr/src/app/dist/src/event-store/event-store.js:20:71
at new Promise ()
at __awaiter (/usr/src/app/dist/src/event-store/event-store.js:16:12)
at VolatileSubscriptionOperation.onDropped [as _subscriptionDropped] (/usr/src/app/dist/src/event-store/event-store.js:100:16)
at /usr/src/app/node_modules/node-eventstore-client/lib/dist.js:3831:14
at VolatileSubscriptionOperation.module.exports.SubscriptionOperation._executeActions (/usr/src/app/node_modules/node-eventstore-client/lib/dist.js:3890:15)
at processImmediate (internal/timers.js:439:21)

Could it be caused by the size of payload and the amount of events are too much? I didn’t think it would be the problem, but I don’t know what else could cause this issue.

Edited: tried upgrading but didn’t solve the problem.
We also receive out of mem error, but I’m not sure if it’s related to above error message.I’m using Digitalocean 2vCPU 2GB RAM. Should I upgrade it or could I switch to 1vCPU 3 GB RAM? Would it be wise to do so or do you think if I can solve the problem above it would also solve this problem as well?

The original concept of promises was that you could have a rejected promise sitting around for some time before attaching a catch handler to it. For example, Firefox used to warn of uncaught rejection errors only when a rejected promise with no rejection handler was garbage collected from memory.

Somebody decided that JavaScript programmers couldn’t be trusted with managing promise rejections properly and changed the HTML spec to require browsers to throw “unhandled promise rejection” errors if a rejected promise has no rejection handlers added before code returns to the event loop.

On a case by case basis you can prevent the host being notified by adding a rejection handler that is never used. The reasoning is that adding a dummy rejection handler to a promise means that should it be rejected it has a rejection handler already - or if it was rejected the host is notified the promise now has a rejection handler - and you can call then and catch multiple times on the same promise.

A nice way to wait for several Promises to resolve to use the Promise.all function. It expects an Array of Promises, and produces a Promise that resolves to an Array containing the values that the individual Promises resolved to. Furthermore, it only resolves after the last Promise resolves. If any of its input Promises rejects, then the entire Promise.all expression rejects as well. It effectively “runs” all of its input processes “at the same time”, emulating the classic “fork-join” pattern.

@engineers.dope, this package is not supported by us. I recommend using our gRPC client (https://www.npmjs.com/package/@eventstore/db-client) or creating an issue on the repository you linked.
Did you already try using our gRPC client?

You can also have a look at our blog post about using NestJS with EventStoreDB written by James Hickey: https://www.eventstore.com/blog/building-a-nestjs-web-application-with-eventstoredb.