Skip to content

Commit

Permalink
Move callback outside of try.
Browse files Browse the repository at this point in the history
Leaving the callback inside try leads to any programmer error inside the callback being captured
and the callback re-called with that as an error.

In normal nodejs flow this may turn into an infinite loop.
In promisified flow this leads to cryptic errors about callback being called twice.
  • Loading branch information
dantman committed Oct 22, 2015
1 parent 01de7a9 commit b26eeb9
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion src/util.js
Original file line number Diff line number Diff line change
Expand Up @@ -134,12 +134,12 @@ util.getTextReplacement = function( src, relativeTo, callback )
try
{
var replacement = util.getInlineFileContents( src, relativeTo );
return callback( null, replacement );
}
catch( err )
{
return callback( err );
}
return callback( null, replacement );
}
};

Expand Down

0 comments on commit b26eeb9

Please sign in to comment.