You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Command 'Remote-Containers: Open Folder in Container...' results in an error (Cannot read property 'forceNewWindow' of null) #111898
Alexandru Dima (@alexdima) I pass undefined as the second argument to the vscode.openFolder command and that ends up being null on the renderer side (that then slips past a default initializer for a function argument). I didn't immediately see any recent changes in the messaging code, do you have any idea what might be going on?
I think the rpc protocol is fine, since I had the same bug a while ago. It has a unit test in place for that here so I do not think that has regressed.
Johannes Rieken (@jrieken) I think the command arguments serialization might suffer from the undefined becomes null problem. IIRC this happened for the rpc protocol when using JSON.parse(JSON.stringify([0,undefined,2])) which becomes [0,null,2]
What has changes is that some commands are now registered in the renderer and invoked with slightly different argument structured (I believe is was a single object before). Adding Benjamin Pasero (@bpasero) because API commands should be somewhat graceful.
Also back to Alexandru Dima (@alexdima) because I do see this as an IPC issue. We are calling this with undefined and receiving null.
Johannes Rieken (@jrieken) The rpc layer does not recurse into arguments. It behaves the same as with sending other special types, like VSBuffer. So you can send top level undefined arguments, but not undefined deeply nested in the value of an argument.
So for example:
$myMethod(1, undefined, 10) will arrive as $myMethod(1, undefined, 10)
but $myMethod(1, [1, undefined, 2], 10) will arrive as $myMethod(1, JSON.parse(JSON.stringify([1, undefined, 2])), 10).
I am sorry, but there is nothing I can do on my side because I call JSON.stringify on each argument (except for undefined and VSBuffer arguments) and I don't want to reimplement JSON.stringify and JSON.parse for perf reasons. The contract is that your data arrives on the other side via JSON, plus the extra stuff I did on top that I do give top level undefined arguments as undefined and top level VSBuffer as VSBuffer. But I cannot walk into objects, we had that and removed it because it was slowing everything down.
Makes sense. I didn't expect you to tackle this and generally I try to be defensive wrt undefined/null when they come via RPC. Leaving this to Benjamin Pasero (@bpasero) to more graceful
Activity
chrmarti commentedon Dec 4, 2020
Alexandru Dima (@alexdima) I pass
undefinedas the second argument to thevscode.openFoldercommand and that ends up beingnullon the renderer side (that then slips past a default initializer for a function argument). I didn't immediately see any recent changes in the messaging code, do you have any idea what might be going on?alexdima commentedon Dec 4, 2020
I think the rpc protocol is fine, since I had the same bug a while ago. It has a unit test in place for that here so I do not think that has regressed.
Johannes Rieken (@jrieken) I think the command arguments serialization might suffer from the
undefinedbecomesnullproblem. IIRC this happened for the rpc protocol when usingJSON.parse(JSON.stringify([0,undefined,2]))which becomes[0,null,2]jrieken commentedon Dec 4, 2020
What has changes is that some commands are now registered in the renderer and invoked with slightly different argument structured (I believe is was a single object before). Adding Benjamin Pasero (@bpasero) because API commands should be somewhat graceful.
Also back to Alexandru Dima (@alexdima) because I do see this as an IPC issue. We are calling this with
undefinedand receivingnull.alexdima commentedon Dec 4, 2020
Johannes Rieken (@jrieken) The rpc layer does not recurse into arguments. It behaves the same as with sending other special types, like
VSBuffer. So you can send top levelundefinedarguments, but notundefineddeeply nested in the value of an argument.So for example:
$myMethod(1, undefined, 10)will arrive as$myMethod(1, undefined, 10)$myMethod(1, [1, undefined, 2], 10)will arrive as$myMethod(1, JSON.parse(JSON.stringify([1, undefined, 2])), 10).I am sorry, but there is nothing I can do on my side because I call
JSON.stringifyon each argument (except forundefinedandVSBufferarguments) and I don't want to reimplementJSON.stringifyandJSON.parsefor perf reasons. The contract is that your data arrives on the other side viaJSON, plus the extra stuff I did on top that I do give top levelundefinedarguments asundefinedand top levelVSBufferasVSBuffer. But I cannot walk into objects, we had that and removed it because it was slowing everything down.jrieken commentedon Dec 4, 2020
Makes sense. I didn't expect you to tackle this and generally I try to be defensive wrt undefined/null when they come via RPC. Leaving this to Benjamin Pasero (@bpasero) to more graceful
fix #111898
fix #111898
fix #111898 (#111928)
fix #111898 on master