Replies: 2 comments
-
|
Hey @yvele, thanks for opening this discussion. To me it seems that our default json replacer function needs to be improved here. Instead of actually detecting cycles in the object reference tree it is tracking if a reference was seen before. While this is detecting cycles correctly, it also leads to false positives like the example you shared. While Let me transform this discussion into an issue. |
Beta Was this translation helpful? Give feedback.
-
|
Opened an issue here: #4721. Let's move the conversation to this issue. I will close the discussion in favor of the issue. |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
-
When logging an object that has multiple references to the same object (non-circular), it seems that the logger removes the duplicate reference entirely, even though it’s not circular.
You can see that
ref2, even though it’s not circular, is completely removed due to the implementation of circular reference removal.This comes from the current implementation here:
powertools-lambda-typescript/packages/logger/src/Logger.ts
Lines 739 to 772 in b387db0
I would expect both references (
ref1andref2) to appear in the log output, since the structure is not circular, it’s just a shared reference.If it’s intentional, could you explain the reasoning, e.g., is the goal to enforce unique object serialization or minimize payload size?
It might also be useful to add a unit test to explicitly cover this case (or document the current behavior) to make the intention clear for contributors.
Beta Was this translation helpful? Give feedback.
All reactions