node-restify icon indicating copy to clipboard operation
node-restify copied to clipboard

stop handling `then` when `next` is called

Open twksos opened this issue 1 year ago • 1 comments

Pre-Submission Checklist

  • [v] Opened an issue discussing these changes before opening the PR
  • [v] Ran the linter and tests via make prepush
  • [v] Included comprehensive and convincing tests for changes

Issues

Closes:

  • Issue #1935

Summarize the issues that discussed these changes

currently, the async function handling does not meet user's expectation. a function returning Promise can still have the next param and:

  • it could get called twice.
  • if user send out an error through the next, the promise could still resolve.

Changes

add a local variable to check whether next is called and wrap the next function.

What does this PR do?

  • in chain.js prevent further Promise handling if next is called.
  • add tests

twksos avatar Feb 08 '23 22:02 twksos

Hi @mmarchini, could you review this PR when you have time?

twksos avatar Jul 21 '23 21:07 twksos