Skip to content

fix(http): return after reject so promise doesn't double-settle (#11)#32

Open
SAY-5 wants to merge 1 commit intoshoneslab:masterfrom
SAY-5:fix/issue-11-double-settle-promise
Open

fix(http): return after reject so promise doesn't double-settle (#11)#32
SAY-5 wants to merge 1 commit intoshoneslab:masterfrom
SAY-5:fix/issue-11-double-settle-promise

Conversation

@SAY-5
Copy link
Copy Markdown

@SAY-5 SAY-5 commented Apr 30, 2026

Fixes #11. src/http.js had two paths where reject(...) was called but execution continued to a later resolve(result), settling the same promise twice — first as rejected, then as fulfilled (the second settlement is a silent no-op but the wrong outcome wins for the caller's mental model and any logging that observes both signals).

Locations

  1. Non-2xx status code (line 22): reject was called, then the request kept draining data/end and the parser eventually invoked resolve(result).
  2. XML parse error inside xml2jsparser callback (line 33): reject then resolve(result) ran on the next line unconditionally.

Added return to both reject paths so the function exits cleanly on error.

Test plan

  • node -c src/http.js syntax check
  • No callers depended on the post-reject continuation; the resolve was unreachable in practice for most consumers but the spurious follow-on resolve(undefined) from the parser path could produce confusing logs

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

resolve, reject in http.js missing return

1 participant