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
{{ message }}
This repository was archived by the owner on Apr 22, 2023. It is now read-only.
// Constructor of some model class.functionWebSite(domain){this.domain=domain;}// Inheriting from EventEmitter.varEventEmitter=require('events').EventEmitter;WebSite.prototype=newEventEmitter();// Create instance. varwebsite=newWebSite("google.com");// Add event handler.website.on("ping",function(){console.log("pong");});// Try to emit event.website.emit("ping");> TypeError: Objectgoogle.comhasnomethod'enter'atEventEmitter.emit(events.js:80:19)...// What? How? Hmm..
What happens here is that EventEmitter uses a field named 'domain' to store its domain, and tries to call this.domain.enter(), which is neither documented, nor expected.
Solution: At least rename it to '_domain' (like '_events', internal by convention).
Background: I have a Mongoose model with field 'domain' and cannot rename it easily as the database depends on it. Therefore I have no choice but to get back to Node v0.6, until this bug is fixed. Please, help!