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
Updated the title, there is no difference in loading behaviour but I feel __nodeRequire() is really a hack from the times where we could not write async import(...). It also gives us proper typing.
Yeah, it's still equally sync. Writing async import 'foo' is the same as writing new Promise(resolve => load_module('foo')). It still helps because it auto-generates load_module for you.
I get an error that vsda can not be found. Andre Weinand (@weinand) should we specify that we use vsda somewhere?
Putting declare module 'vsda' {} anywhere in your code should help
Thanks for advice.
Added vsda.d.ts and fixed the issue in rawDebugSession
Now strangly the RemoteAgentConnection can not await import('keytar'); since that import violates the ts lint import rule. Benjamin Pasero (@bpasero) should I put the vsda.d.ts in some other typings folder, since the RemoteAgentConnection can not depend on it from src/typings?
Benjamin Pasero (@bpasero) I can look into moving remoteAgentConnection to node. Martin Aeschlimann (@aeschli) does this make sense to you? I see some modules from common depend on it, so I wold probalby split the remoteAgentConnection to have the implementation in node and interfaces in common
Benjamin Pasero (@bpasero) I looked into the remoteAgentConnection and it is a bit more complex. The issue is that it can not be nicely split up between common and node since the actual function that uses require.__$__nodeRequire syntax is used by other modules not living in node.
We seem to use the vsda module for signing when in the native environment. And due to that I believe we need two implementations of connectToRemoteExtensionHostAgent one for the native and one for the rest. So we basically get rid of this check.
I could also pass in the signer as part of the options, so the remoteAgentConnection stays in common and different clients would pass a signer.
Christof Marti (@chrmarti) I noticed this and it is a bad hack, but I am not sure why that was done. The right solution would be to introduce a service for this and implement it in browser and node environments.
fyi
There is a difference in the behaivor of the __nodeRequiere() and await import('')
When the module is missing, the second pattern will only throw the error the first time you import the moduel.
Due to that I had to cache the promise to always have the expected behavior for the missing module
Activity
isidorn commentedon May 27, 2019
Andre Weinand (@weinand) actually added the dependency to
vsda. However when I change the code toawait import('vsda');I get an error thatvsdacan not be found. Andre Weinand (@weinand) should we specify that we usevsdasomewhere?Code pointer https://github.com/Microsoft/vscode/blob/a00a9a29452546c6f5018f89d5c9f051f841dd38/src/vs/workbench/contrib/debug/electron-browser/rawDebugSession.ts#L531
joaomoreno commentedon May 27, 2019
Isn't this still going sync, deep down?
weinand commentedon May 27, 2019
Isidor Nikolic (@isidorn)
__$__nodeRequirecomes from the vscode.loader. The owner of that package (alexandrudima or Johannes Rieken (@jrieken)) should advise how to replace this with anasync import.BTW, 'vsda' is used in two places: RawDebugSession and RemoteAgentConnection. Please fix both of them since Alex is out.
bpasero commentedon May 27, 2019
Isidor Nikolic (@isidorn) yeah that sucks, we probably need to throw in a
vsda.d.tsintosrc/typingsto make TS happy :-|[-]Avoid sync __nodeRequire()[/-][+]Avoid __nodeRequire()[/+]bpasero commentedon May 27, 2019
Updated the title, there is no difference in loading behaviour but I feel
__nodeRequire()is really a hack from the times where we could not writeasync import(...). It also gives us proper typing.jrieken commentedon May 27, 2019
Yeah, it's still equally sync. Writing
async import 'foo'is the same as writingnew Promise(resolve => load_module('foo')). It still helps because it auto-generatesload_modulefor you.Putting
declare module 'vsda' {}anywhere in your code should helpisidorn commentedon May 27, 2019
Thanks for advice.
Added vsda.d.ts and fixed the issue in
rawDebugSessionNow strangly the
RemoteAgentConnectioncan notawait import('keytar');since that import violates the ts lint import rule. Benjamin Pasero (@bpasero) should I put the vsda.d.ts in some other typings folder, since theRemoteAgentConnectioncan not depend on it fromsrc/typings?add vsda.d.ts
6 remaining items
Tyriar commentedon Jun 4, 2019
Terminal ones removed in #74858
isidorn commentedon Jun 5, 2019
Benjamin Pasero (@bpasero) I can look into moving
remoteAgentConnectiontonode.Martin Aeschlimann (@aeschli) does this make sense to you? I see some modules from common depend on it, so I wold probalby split the remoteAgentConnection to have the implementation in
nodeandinterfacesincommonremove __$__nodeRequire
Avoid __nodeRequire() (#74398)
chrmarti commentedon Jun 5, 2019
Benjamin Pasero (@bpasero) Do you know why mainThreadKeytar.ts was placed in the 'browser' and not the 'node' folder? Maybe that was an oversight.
Avoid __nodeRequire() (#74398)
isidorn commentedon Jun 5, 2019
Benjamin Pasero (@bpasero) I looked into the
remoteAgentConnectionand it is a bit more complex. The issue is that it can not be nicely split up betweencommonandnodesince the actual function that usesrequire.__$__nodeRequiresyntax is used by other modules not living in node.We seem to use the
vsdamodule for signing when in the native environment. And due to that I believe we need two implementations ofconnectToRemoteExtensionHostAgentone for the native and one for the rest. So we basically get rid of this check.I could also pass in the signer as part of the options, so the remoteAgentConnection stays in common and different clients would pass a signer.
bpasero commentedon Jun 5, 2019
Christof Marti (@chrmarti) I noticed this and it is a bad hack, but I am not sure why that was done. The right solution would be to introduce a service for this and implement it in
browserandnodeenvironments.Isidor Nikolic (@isidorn) I do not understand
isidorn commentedon Jun 11, 2019
fyi
There is a difference in the behaivor of the
__nodeRequiere()andawait import('')When the module is missing, the second pattern will only throw the error the first time you import the moduel.
Due to that I had to cache the promise to always have the expected behavior for the missing module
https://github.com/Microsoft/vscode/blob/18f4630bc51a3d87c7b31d96ca9c8ea95aa649b0/src/vs/platform/sign/node/signService.ts#L15
isidorn commentedon Jun 11, 2019
Created #75257 as a follow up