2
0
mirror of https://github.com/tenrok/axios.git synced 2026-06-17 19:21:29 +03:00
Files
axios/lib
AKIBUZZAMAN AKIB f2b903fcea refactor(utils): use WeakSet for cycle detection in toJSONObject (#10832)
* refactor(utils): use WeakSet for cycle detection in toJSONObject

Replace fixed-size Array(10)+indexOf stack with WeakSet using
add-on-descent/delete-on-ascent to preserve path (ancestor-only) semantics.

The delete on ascent is the critical correctness detail — a naive WeakSet
swap without delete treats shared DAG siblings as already-seen and drops
them as undefined, the exact regression introduced in #7230.

Perf is a secondary benefit: WeakSet.has is O(1) amortised vs O(n)
Array.indexOf, measurable on deeply nested objects.

- Compress verbose 3-line comment to one line (references #7230)
- Group new DAG regression tests under describe('cycle / DAG handling')

Fixes #10807

* chore: added should serialize non-cyclic structures deeper than the old Array(10) cap

---------

Co-authored-by: AKIBUZZAMAN AKIB <>
Co-authored-by: Jay <jasonsaayman@gmail.com>
2026-05-05 20:05:17 +02:00
..