-
Notifications
You must be signed in to change notification settings - Fork 2.5k
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
Fix "Converting circular structure to JSON" Error #5121
Conversation
try { | ||
return JSON.parse(JSON.stringify(value)); | ||
} catch (e) { | ||
return; |
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.
VS Code translates circular ref to null
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.
changed to return undefined
@vinokurig How can one verify it? Is it about: #4975? |
@akosyakov looks like it should solve the issue, I'll check it |
1b81e92
to
a5e02f0
Compare
Signed-off-by: Igor Vinokur <[email protected]>
@akosyakov I've launched the microclimate-vscode plugin (#4975) and the issue was not reproduced: |
Why cannot we do it the same like VS Code do: https://github.com/microsoft/vscode/blob/0fde6619172c9f04c41f2e816479e432cc974b8b/src/vs/workbench/services/extensions/common/rpcProtocol.ts#L22-L28 Without caches and serializing/deserializing all objects (which look expensive)? It seems to be more performant, compatible with VS Code and simple. Plus apply it in all places, not only for |
@akosyakov The plugin didn't work with that solution. Probably VsCode uses another replacers. |
return undefined; | ||
} | ||
} | ||
cache.push(value); |
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.
How does it ever reach this code?
@vinokurig Don't you think it is bad to serilaize and parse each property of each object? I don't think this solution is in the right direction. VS Code replacer only handles URI i wonder what we do differently that we have to go for such expensive strategies. |
I also agree that the fix should be better than what is being done. It's too costly |
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.
somehow the fix should avoid to unwrap/wrap each element
…\n Signed-off-by: Ariel Bentolila <[email protected]>
…\n Signed-off-by: Ariel Bentolila <[email protected]>
Hi, |
…\n Signed-off-by: Ariel Bentolila <[email protected]> Signed-off-by: Ariel Bentolila <[email protected]>
After some more investigation and the latest PR I made #5196, I think I figured out what is fundamentally wrong in tree views for plugin/vscde-extensions in Theia, which exposes this issue in many cases: The way the tree view is implemented (TreeViewsExt, TreeViewItem, tree-view-main.tsx etc) is that the server-side object representing a TreeItem is moved (via json-rpc) from server to client upon getChildren call (specifically the original object is placed under This back and forth move of the actual object of the tree-item is the source of some major problems:
The right way to do it (and I guess vscode do exactly that), is to avoid sending these objects to the browser. Upon menu or click on action icon, send to the server a call indicating that the menu was triggered, or the action-icon was clicked. the actual for the command behind the menu or action icon would be called from the server-side, passing the original item's object (with all its functions and private data). What do you think? I believe this would solve #4975 as well. |
@ariel-bentu 👍 |
I updated PR #5196 to do that. please help to promote its acceptance. |
Will fix in another way |
Fix "Converting circular structure to JSON" Error that causes when launching VsCode GitHub-Pull-Request-Plugin.
Is needed for eclipse-che/che#11867