Skip to content

Conversation

ericlln
Copy link
Contributor

@ericlln ericlln commented Sep 9, 2025

Exporting logs is currently failing with this error message:

Uncaught TypeError TypeError: Converting circular structure to JSON
    --> starting at object with constructor 'LinkedHashMap'
    |     property 'hashCodeMap' -> object with constructor 'InternalHashCodeMap'
    --- property 'host_0' closes the circle
    at getReduxDataString (/Users/ericlin/dev/web-client-ui/packages/log/src/LogExport.ts:125:15)

We are handling circular references in makeSafeToStringify() before calling JSON.stringify(), but it seems that some of them are not being handled properly. This was tricky to debug since it was unclear to me where/how exactly it was failing. I spent some time trying to fix our custom implementation before settling with a library, safe-stable-stringify (MIT license), that would handle circular structures and BigInt in a performant way.

There are a few differences between our previous custom implementation vs safe-stable-stringify:

  • Circular references are replaced with “[Circular]”, whereas before we also showed the path that the reference points to. This is a requested feature that doesn't seem will be worked on Feature request: named circular references BridgeAR/safe-stable-stringify#43
  • The order of keys are different when compared to previous logs. By default the library guarantees a deterministic key order instead of relying on insertion order, but this can be disabled to match the former behaviour if desired.
  • BigInts are converted to a number instead of a string in this library

The blacklist was updated with new entries to reduce the log size and prevent length errors when exporting:

  • For instance, the client object, which was already blacklisted, was also found in a few other paths, which have now been blacklisted as well.

Tested by:

  • Exporting logs on an account with many queries successfully with a reasonable size (62kb)
  • Comparing the result to logs from before this issue and verified that useful data has not been omitted.

Note:
After more testing, I tried using the new blacklist with our original custom implementation, and it appears to also work. I narrowed it down to draftManager/draftStorage, which seemed to be causing the circular structure error.

However, when using the library, there is no error when serializing this key, albeit producing a 31mb log file, indicating that there is still something wrong with our implementation. We could solve this specific issue by blacklisting this key, but switching to a library might be a better idea to prevent such cases in the future.

@ericlln ericlln requested a review from a team September 9, 2025 18:42
@ericlln ericlln self-assigned this Sep 9, 2025
@ericlln ericlln requested review from dgodinez-dh and removed request for a team September 9, 2025 18:42
Copy link

codecov bot commented Sep 9, 2025

Codecov Report

❌ Patch coverage is 66.66667% with 1 line in your changes missing coverage. Please review.
✅ Project coverage is 44.57%. Comparing base (53c4d26) to head (a5eb61f).

Files with missing lines Patch % Lines
packages/log/src/LogExport.ts 66.66% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #2531      +/-   ##
==========================================
- Coverage   44.59%   44.57%   -0.02%     
==========================================
  Files         764      764              
  Lines       42825    42807      -18     
  Branches    10769    10963     +194     
==========================================
- Hits        19096    19083      -13     
+ Misses      23718    23713       -5     
  Partials       11       11              
Flag Coverage Δ
unit 44.57% <66.66%> (-0.02%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@mofojed mofojed merged commit f2d2317 into deephaven:main Sep 10, 2025
11 checks passed
@github-actions github-actions bot locked and limited conversation to collaborators Sep 10, 2025
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants