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
Seeing an issue where .once( 'data' ... ) on a stream will only be hit if there is an .on( 'data'... ) call somewhere on the same eventemitter object.
I've spent an hour or so in the code trying to figure out the issue, but I am stumped. Could you give me any guidance on why a .once() would not be hit unless there's a .on() for the same event type?
Specifically I am seeing this using the node-postgres module with longjohn included. In their connection module, I tracked it down to this:
// without this, .once below seems inconsistentthis.stream.on('data',function(){varnop=1;});this.stream.once('data',function(buffer){varresponseCode=buffer.toString('utf8');if(responseCode!='S'){returnself.emit('error',newError('The server does not support SSL connections'));}vartls=require('tls');self.stream=tls.connect({socket: self.stream,servername: host,rejectUnauthorized: self.ssl.rejectUnauthorized,ca: self.ssl.ca,pfx: self.ssl.pfx,key: self.ssl.key,passphrase: self.ssl.passphrase,cert: self.ssl.cert,NPNProtocols: self.ssl.NPNProtocols});self.attachListeners(self.stream);self.emit('sslconnect');self.stream.on('error',function(error){self.emit('error',error);});});
If I don't add the .on( 'data'...) the .once( 'data'... will never be hit while longjohn is loaded.
The text was updated successfully, but these errors were encountered:
Seeing an issue where .once( 'data' ... ) on a stream will only be hit if there is an .on( 'data'... ) call somewhere on the same eventemitter object.
I've spent an hour or so in the code trying to figure out the issue, but I am stumped. Could you give me any guidance on why a .once() would not be hit unless there's a .on() for the same event type?
Specifically I am seeing this using the node-postgres module with longjohn included. In their connection module, I tracked it down to this:
If I don't add the .on( 'data'...) the .once( 'data'... will never be hit while longjohn is loaded.
The text was updated successfully, but these errors were encountered: