Uncaught exceptions on hex char been deliverd to verror.js
when creating new restify error with a "%25" as a prefix and than one of the following chars (e,E,f,g,G,d etc...) the application will break with an uncaught exception. it looks like verror uses sprintf, and it encodes "%25" a real "%" delivered as an argument. this end with "Error: next shouldn't be called more than once"
Hi @kobymolcho, do you have a sample code snippet here to reproduce the exact exception you are seeing? Anything involving the % does sound sprintf related but want to make sure we're looking at the right thing.
try this out: server.get('/', function(req, res, next) { var err = new restify.errors.NotFoundError('1234%25d1234'); return next(err); });
Thanks! What version of restify-errors are you using?
If you reduce it down to just these two lines, can you confirm the exception you are seeing:
const errs = require('restify-errors');
var err = new errs.NotFoundError('1234%25d1234');
/Users/aliu/Sandbox/test/node_modules/extsprintf/lib/extsprintf.js:97
throw (jsError(ofmt, convposn, curconv,
^
Error: format string "1234%25d1234": conversion specifier "%25d" at character 5 has no matching argument (too few arguments passed)
i'm using 6.4.0, and yes - i can confirm this two lines throws..
node_modules/extsprintf/lib/extsprintf.js:72 throw (new Error('too few args to sprintf'));
Thanks for the confirmation. This is expected behavior - you can work around it for now:
var err = new errs.NotFoundError('%s', '1234%25d1234');
Alternatively, some work is happening over in joyent/node-verror#57 to allow disabling of printf via a constructor option.
That's a great tip.. Thank you!
As it looks like this was resolved (and behavior was expected), I'll close this ticket now. @kobymolcho let us know if that isn't the case.