-
Notifications
You must be signed in to change notification settings - Fork 9
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
Remove circular references when stringifying an object #11
Conversation
Thanks! This seems to be working fine when testing on Binder: Using a snippet like in: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/JSON/stringify#issue_with_json.stringify_when_serializing_circular_references |
@@ -169,13 +169,31 @@ const extension: JupyterFrontEndPlugin<void> = { | |||
const _trace = console.trace; | |||
const _table = console.table; | |||
|
|||
// https://stackoverflow.com/a/11616993 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Added a warning message informing the user about the possibility of missing attributes
Binder link working https://mybinder.org/v2/gh/QuantStack/jupyterlab-js-logs/circular-references |
Nice! |
src/index.ts
Outdated
const msg = | ||
'This error contains a object with a circular reference. During the process of removing the reference we could have removed duplicated attributes.\n'; | ||
const obj = JSON.stringify(arg, refReplacer); | ||
cache = []; | ||
console.error(msg, obj); | ||
data += obj; | ||
} catch (e) { | ||
data += ' '; | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe we could do a quick refactor if this piece of code is the same in all cases?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ooh, thanks. I forgot about that.
I'm on it.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks!
Let's wait for CI and a quick check on Binder and this should be good to go. |
Remove circular references when stringifying an object because otherwise, the
JSON.stringify
throws an error.