Skip to content

fix(to-response): only mark true cycles in safeStringify#140

Merged
bytaesu merged 2 commits into
mainfrom
2026-04-29/fix/safe-stringify-shared-refs
Apr 29, 2026
Merged

fix(to-response): only mark true cycles in safeStringify#140
bytaesu merged 2 commits into
mainfrom
2026-04-29/fix/safe-stringify-shared-refs

Conversation

@bytaesu

@bytaesu bytaesu commented Apr 29, 2026

Copy link
Copy Markdown
Member

Copilot AI review requested due to automatic review settings April 29, 2026 11:23
@bytaesu bytaesu added the backport v1.3.x Backport this PR to v1.3.x branch label Apr 29, 2026
@pkg-pr-new

pkg-pr-new Bot commented Apr 29, 2026

Copy link
Copy Markdown

Open in StackBlitz

npm i https://pkg.pr.new/better-call@140

commit: cb08dd6

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Adjusts safeStringify in toResponse to only label true cycles as circular references (matching JSON.stringify behavior for shared-but-non-cyclic references), addressing issue #86.

Changes:

  • Reworked circular detection in safeStringify to check only the current ancestor chain (not “seen before” globally).
  • Updated/added tests to ensure shared object/array references serialize in full while true cycles are still marked.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.

File Description
packages/better-call/src/to-response.ts Updates safeStringify to detect only ancestor-chain cycles using parent tracking + stable IDs.
packages/better-call/src/to-response.test.ts Updates circular-ref expectations and adds coverage for shared non-cyclic references (object + array).

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread packages/better-call/src/to-response.ts
@bytaesu bytaesu merged commit f5e54a1 into main Apr 29, 2026
3 checks passed
@better-release

Copy link
Copy Markdown

Successfully created backport PR for v1.3.x:

bytaesu added a commit that referenced this pull request Apr 29, 2026
(cherry picked from commit f5e54a1)

Co-authored-by: Taesu <166604494+bytaesu@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

backport v1.3.x Backport this PR to v1.3.x branch

Projects

None yet

Development

Successfully merging this pull request may close these issues.

safeStringify should only mark true cycles as circular references, not shared objects

2 participants