You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I was trying to figure out why I had an obscure EventEmitter error, and it took me very long to figure out that I missed out new.
Most of the express ecosystem constructs instances without using new, which is probably why I was confused. I'm not suggesting new is completely dropped as that would break everyone else's code, but that not using new should work as well.
It should be quite straight forward to implement. For plain node, this works:
> function X() { if (this === global) return new X(); this.y = 2 }; [X(), new X()]
[ X { y: 2 }, X { y: 2 } ]
I'm not sure if this would work with bundlers.
If you don't want to allow that behaviour, it would be nice to at least throw an error saying that you didn't use new, instead of resulting in this getting thrown:
events.js:85
if (this._events === undefined ||
^
TypeError: Cannot read property '_events' of undefined
at EventEmitter.init (events.js:85:12)
at EventEmitter (events.js:44:21)
at Store (/app/node_modules/express-session/session/store.js:33:16)
at KnexStore (/app/node_modules/connect-session-knex/index.js:190:9)
at Object.<anonymous> (/app/src/app.js:20:24)
...
The text was updated successfully, but these errors were encountered:
I was trying to figure out why I had an obscure
EventEmitter
error, and it took me very long to figure out that I missed outnew
.Most of the express ecosystem constructs instances without using
new
, which is probably why I was confused. I'm not suggestingnew
is completely dropped as that would break everyone else's code, but that not usingnew
should work as well.It should be quite straight forward to implement. For plain node, this works:
I'm not sure if this would work with bundlers.
If you don't want to allow that behaviour, it would be nice to at least throw an error saying that you didn't use
new
, instead of resulting in this getting thrown:The text was updated successfully, but these errors were encountered: