Commit 2e288e4
Fix auth() to handle partial success for address families (#14)
* Initial plan
* Fix auth() to use Promise.allSettled for dual-stack knock tolerance
Replace Promise.all with Promise.allSettled in auth() so that a single
unreachable address family (e.g. IPv6 ENETUNREACH) does not cause the
entire auth call to fail when the knock to the other family succeeded.
Now auth() only throws (with AggregateError) when ALL knocks fail.
Also bump tsconfig target to ES2021 for AggregateError type support.
Closes #13
Agent-Logs-Url: https://github.com/84codes/sparoid.js/sessions/c1d08905-5aa2-41cb-95f6-0515c412e206
Co-authored-by: snichme <102988+snichme@users.noreply.github.com>
* Guard against empty results array in auth() knock check
Agent-Logs-Url: https://github.com/84codes/sparoid.js/sessions/c1d08905-5aa2-41cb-95f6-0515c412e206
Co-authored-by: snichme <102988+snichme@users.noreply.github.com>
* test: make knock-failure tests deterministic via socket mocking
The "all knocks fail" and partial-success tests depended on real UDP/IPv6
behavior (sending to 100::1, dual-stack localhost), so their outcome varied
with the host's IPv6 routing — flaky across environments (Copilot review on #14).
Mock dgram.createSocket so send() outcomes are controlled directly:
- all sends fail -> auth() rejects with AggregateError
- one send fails, one succeeds -> auth() resolves (true partial-success path,
which the old localhost test never actually exercised)
Also ports both tests from the leftover ava API to node:test/assert after the
rebase onto main.
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
---------
Co-authored-by: anthropic-code-agent[bot] <242468646+Claude@users.noreply.github.com>
Co-authored-by: snichme <102988+snichme@users.noreply.github.com>
Co-authored-by: Magnus Landerblom <magnus@landerblom.se>
Co-authored-by: Claude Opus 4.8 (1M context) <noreply@anthropic.com>1 parent a1f2b65 commit 2e288e4
3 files changed
Lines changed: 49 additions & 3 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
47 | 47 | | |
48 | 48 | | |
49 | 49 | | |
50 | | - | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
51 | 57 | | |
52 | 58 | | |
53 | 59 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | | - | |
| 1 | + | |
2 | 2 | | |
3 | 3 | | |
4 | 4 | | |
5 | 5 | | |
6 | 6 | | |
7 | 7 | | |
8 | 8 | | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
9 | 21 | | |
10 | 22 | | |
11 | 23 | | |
| |||
37 | 49 | | |
38 | 50 | | |
39 | 51 | | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
| 59 | + | |
| 60 | + | |
| 61 | + | |
| 62 | + | |
| 63 | + | |
| 64 | + | |
| 65 | + | |
| 66 | + | |
| 67 | + | |
| 68 | + | |
| 69 | + | |
| 70 | + | |
| 71 | + | |
| 72 | + | |
| 73 | + | |
| 74 | + | |
| 75 | + | |
| 76 | + | |
| 77 | + | |
| 78 | + | |
| 79 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | 1 | | |
2 | 2 | | |
3 | | - | |
| 3 | + | |
4 | 4 | | |
5 | 5 | | |
6 | 6 | | |
| |||
0 commit comments