Re: [nodejs] Re: Writing to closed connection = Boom!

2012-04-23 Thread steven loe
 I missed the 'writable' property. That's a big help.

Thanks very much for your help!


> What about listening for the 'error' event and/or checking if the
> 'writable' property of the socket is set to false?
>
>
>

-- 
Job Board: http://jobs.nodejs.org/
Posting guidelines: 
https://github.com/joyent/node/wiki/Mailing-List-Posting-Guidelines
You received this message because you are subscribed to the Google
Groups "nodejs" group.
To post to this group, send email to nodejs@googlegroups.com
To unsubscribe from this group, send email to
nodejs+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/nodejs?hl=en?hl=en


Re: [nodejs] Re: Writing to closed connection = Boom!

2012-04-21 Thread Jann Horn
On Sat, Apr 21, 2012 at 06:11:08AM -0700, P. Douglas Reeder wrote:
> In addition to dealing with this directly, make sure you have an
> uncaught exception handler:
> 
> process.on('uncaughtException', function (err) {
>   console.error("caught by event loop: ", err.stack);
> });

Don't do that. When this event fires, you should clean up everything that needs 
to be cleaned up and exit. Just printing the error and going on is not a good 
idea because your program might be in an inconsistent state. For example, look 
at this piece of code:

user.firstname = uppercaseFirst(options.firstname)
user.lastname = uppercaseFirst(options.lastname)

However, options.lastname unfortunately is null for some weird reason and 
uppercaseFirst crashes. Now, this users first name was changed but his last 
name is unaltered. You don't want to go on working with data like that.


pgpqJRWbZdbQu.pgp
Description: PGP signature


[nodejs] Re: Writing to closed connection = Boom!

2012-04-21 Thread P. Douglas Reeder
In addition to dealing with this directly, make sure you have an
uncaught exception handler:

process.on('uncaughtException', function (err) {
console.error("caught by event loop: ", err.stack);
});


On Apr 20, 6:43 pm, steven loe  wrote:
> Node thinks the connection is still open. When node tries to write to that
> connection, node crashes.

-- 
Job Board: http://jobs.nodejs.org/
Posting guidelines: 
https://github.com/joyent/node/wiki/Mailing-List-Posting-Guidelines
You received this message because you are subscribed to the Google
Groups "nodejs" group.
To post to this group, send email to nodejs@googlegroups.com
To unsubscribe from this group, send email to
nodejs+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/nodejs?hl=en?hl=en


[nodejs] Re: Writing to closed connection = Boom!

2012-04-20 Thread mscdex
On Apr 20, 7:10 pm, mscdex  wrote:
> On Apr 20, 6:43 pm, steven loe  wrote:
>
> > However, if the network were to have a problem (for instance someone
> > unplugs and replugs an ethernet cable on the client computer). The socket
> > connection is broken, but the server does not get an 'end' 'close' or other
> > event that I can see.
>
> What about listening for the 'error' event and/or checking if the
> 'writable' property of the socket is set to false?

Additionally, you may want to think about sending some kind of
heartbeat/ping message every so often.

-- 
Job Board: http://jobs.nodejs.org/
Posting guidelines: 
https://github.com/joyent/node/wiki/Mailing-List-Posting-Guidelines
You received this message because you are subscribed to the Google
Groups "nodejs" group.
To post to this group, send email to nodejs@googlegroups.com
To unsubscribe from this group, send email to
nodejs+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/nodejs?hl=en?hl=en


[nodejs] Re: Writing to closed connection = Boom!

2012-04-20 Thread mscdex
On Apr 20, 6:43 pm, steven loe  wrote:
> However, if the network were to have a problem (for instance someone
> unplugs and replugs an ethernet cable on the client computer). The socket
> connection is broken, but the server does not get an 'end' 'close' or other
> event that I can see.

What about listening for the 'error' event and/or checking if the
'writable' property of the socket is set to false?

-- 
Job Board: http://jobs.nodejs.org/
Posting guidelines: 
https://github.com/joyent/node/wiki/Mailing-List-Posting-Guidelines
You received this message because you are subscribed to the Google
Groups "nodejs" group.
To post to this group, send email to nodejs@googlegroups.com
To unsubscribe from this group, send email to
nodejs+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/nodejs?hl=en?hl=en