stringify on recursive structures
Closed this issue · 1 comments
Zulu-Inuoe commented
stringify
dies on recursive structures:
(h:define-easy-handler (test :uri (h:create-prefix-dispatcher "/test" t)) ()
(standard-page "Hello?"
(jzon:stringify h:*request* :pretty t)))
Control stack guard page temporarily disabled: proceed with caution
[2021-03-21 21:45:02 [ERROR]] Error while processing connection: The condition The condition Control stack exhausted (no more space for function call frames).
This is probably due to heavily nested or infinitely recursive function
calls, or a tail call that SBCL cannot or has not optimized away.
PROCEED WITH CAUTION. occurred with errno: 0. occurred with errno: 0.
At the very least we should have circularity detection by default. per what to do when it's encountered, I am leaning towards having these two options available:
- Silently produce a string with an 'obviously' wrong value, such as
"recursive-ref__request->easy-acceptor->one-thread-per-connection-taskmaster->easy-acceptor"
. - Signal an error with a restart available asking for a value to substitute.
By default, I prefer the 'fail silently' option since it's more DWIM when a user is simply trying to inspect some object
Zulu-Inuoe commented
So I've decided to 180 on this and keep error
-ing on circular references per the spec for in-browser JSON.stringify:
https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/JSON/stringify
This is simpler and likely less controversial