Permalink
Browse files

Gracefully handle invalid data writes

  • Loading branch information...
1 parent 3b3307c commit 9b21d8465be93cf82097b7de659bbe57071ae6fa @kriszyp kriszyp committed Oct 27, 2010
Showing with 5 additions and 1 deletion.
  1. +5 −1 lib/jsgi-node.js
View
@@ -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" ) ) {

0 comments on commit 9b21d84

Please sign in to comment.