JLuboff / connect-mssql-v2

MS SQL Server session store for Express Session
MIT License
5 stars 7 forks source link

UnhandledPromiseRejection -- MSSQLStore.ready #11

Closed JLuboff closed 4 years ago

JLuboff commented 4 years ago

While idle, experienced an UnhandledPromiseRejectionWarning: TypeError: callback is not a function. Calling function - MSSQLStore.ready (private method)

bradtaniguchi commented 4 years ago

When re-doing the types I noticed that all the callback parameters in the store methods could be undefined. I didn't include this in the types settings as I assume everything was working properly.

Since the code is always executing the callback parameter that might be the problem. (it could be undefined or null or something being passed instead)

JLuboff commented 4 years ago

That's a good point. I was thinking I have catch blocks every where, so errors should be handled but you're right, if callback is undefined, its going to throw an unhandled rejection. Perhaps I create an additional event listener this.databaseConnection.on('sessionError', error => this.emit('sessionError', error)); and emit that in the catch blocks and only return the callback with the error if callback is not undefined.

JLuboff commented 4 years ago

Reopening issue as I am still getting TypeError: callback is not a function once hourly.