cloudant / nodejs-cloudant

Cloudant Node.js client library
Apache License 2.0
255 stars 90 forks source link

454 double callback #455

Closed ricellis closed 3 years ago

ricellis commented 3 years ago

Checklist

Description

Correct opportunities for double callbacks

Fixes #454

Approach

When writing tests I noticed that max-age was not correctly parsed from a single set cookie header (only from an array) - so there is one fix to resolve that issue.

Double callback (case 1): In auth plugins for case where an error is encountered during state update. The cookieauth and iamauth plugins are modified to callback(state) in a finally at the end of a promise chain instead of from two places in the onRequest function.

Double callback (case 2): Discovered when updating nock to 13.x (see Test section below). In the case a request is aborted for a retry a double request end event might be received because (to more precisely mirror current Node behaviours the abort event moved into the next tick. To ensure our plugins behave correctly with the aborts the callbacks in lib/clientutils.js processState are deferred to the next tick.

Schema & API Changes

Security and Privacy

Testing

Monitoring and Logging