Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

🐛 Bug: Response.json does not throw error with circular data #831

Open
huancheng-trili opened this issue Feb 20, 2025 · 1 comment
Open
Labels
bug Something isn't working

Comments

@huancheng-trili
Copy link
Collaborator

Description

Response.json does not throw errors with circular data.

Observed behaviour

Stack overflow.

Expected behaviour

An error should have been thrown. With node.js,

> Response.json(a)
Uncaught TypeError: Converting circular structure to JSON
    --> starting at object with constructor 'Object'
    --- property 'a' closes the circle
    at JSON.stringify (<anonymous>)
    at serializeJavascriptValueToJSONString (node:internal/deps/undici/undici:1594:27)
    at Response.json (node:internal/deps/undici/undici:5659:11)

Steps to reproduce

$ jstz repl
>> const a = { b: 1 };
>> a.a = a;
{
   b: 1,
   a: [Cycle]
}
>> Response.json(a)

thread 'main' has overflowed its stack
fatal runtime error: stack overflow
@huancheng-trili huancheng-trili added the bug Something isn't working label Feb 20, 2025
@huancheng-trili
Copy link
Collaborator Author

Confirmed that this is due to a bug in boa.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

1 participant