Skip to content

Commit

Permalink
Gracefully handle invalid data writes
Browse files Browse the repository at this point in the history
  • Loading branch information
kriszyp committed Oct 27, 2010
1 parent 3b3307c commit 9b21d84
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion lib/jsgi-node.js
Expand Up @@ -162,7 +162,11 @@ function Response( response, stream ) {
}

forEachResult = data.body.forEach( function( chunk ) {
response.write( chunk, data.body.encoding || "utf8" );
try{
response.write( chunk, data.body.encoding || "utf8" );
}catch(e){
response.write( "error writing " + chunk + e, data.body.encoding || "utf8" );
}
});

if ( !notDone && forEachResult && ( typeof forEachResult.then === "function" ) ) {
Expand Down

0 comments on commit 9b21d84

Please sign in to comment.