aws / aws-js-sns-message-validator

Apache License 2.0
69 stars 39 forks source link

When provided callback to validate() throws an error that callback is being called again. #26

Open ujasur opened 5 years ago

ujasur commented 5 years ago

Message validator has the issue of calling the provided callback twice. It can cause error where it is assumed that function will be called once. For example:

var v = new MessageValidator('someurl');

function middleware(req, res, next) {
   v.validate(validMessage, function(err, message) {
       console.count('called');
       if (err) { 
          return next(new Error('Validation error:' + err.message )); 
       }
       // some code
       throw new Error('inside callback');
   });
}
rulatir commented 4 years ago

Any news on this? I am considering using this module, but this looks like a showstopper.

jacoor commented 3 years ago

eh, been just hit by this. Searching for other solution. @ujasur made a fork and fixed it. https://github.com/ujasur/aws-js-sns-message-validator/commit/d03aa2409bbcb391f102b10ba4b20b07e1e472fd Thank you!