Skip to content
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

Migrate to new Azure SDK packages #197

Merged
merged 9 commits into from
Jun 26, 2020
Merged

Conversation

RMacfarlane
Copy link
Contributor

@RMacfarlane RMacfarlane commented Jun 23, 2020

#140

Migrate to using the new Azure SDK packages internally, but continue to expose the old credentials object in the API for backcompatability. Introduces a new "credentialsV2" property corresponding to the new credentials object

Copy link
Contributor

@chrmarti chrmarti left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Change looks good. When I try to sign in I get the success page in the browser, but the VS Code statusbar and the App Services view remain empty. (This is on Mac.)

readonly userId: string;
readonly tenantId: string;
readonly credentials: ServiceClientCredentials;
readonly credentialsV2: DeviceTokenCredentials;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is there a more general interface like ServiceClientCredentials in the old SDK? 'Device' refers to the device login flow.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Changed to TokenCredentialsBase, which seems to be the most general interface for the new SDK

@@ -380,7 +380,7 @@ export function createCloudConsole(api: AzureAccount, reporter: TelemetryReporte
// Additional tokens
const [graphToken, keyVaultToken] = await Promise.all([
tokenFromRefreshToken(session.environment, result.token.refreshToken, session.tenantId, session.environment.activeDirectoryGraphResourceId),
tokenFromRefreshToken(session.environment, result.token.refreshToken, session.tenantId, `https://${session.environment.keyVaultDnsSuffix.substr(1)}`)
tokenFromRefreshToken(session.environment, result.token.refreshToken, session.tenantId, `https://${session.environment.keyVaultDnsSuffix!.substr(1)}`)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I wonder if the is a good fallback for when keyVaultDnsSuffix is not available. Maybe CloudShell works without a KeyVault token? (It used to.)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, I just tried without a KeyVault token and it seemed to work fine without it. I'll change this to make the keyVault token optional

@chrmarti chrmarti self-requested a review June 23, 2020 14:09
@chrmarti
Copy link
Contributor

@RMacfarlane Actually everything works when running out-of-source, only when installing the packaged VSIX it somehow didn't. Can you give that a try?

@RMacfarlane
Copy link
Contributor Author

RMacfarlane commented Jun 23, 2020

Was it sign in that didn't work? I've just tried packaging and running it as a VSIX and have been able to sign in and open a cloud console.

Edit: Ah, you answered that above. I'll self host with it for the rest of today and see if I can repro

@chrmarti
Copy link
Contributor

I see the following in the console when running with the VSIX, but not when running with yarn watch. Do you see that? Maybe the minifier somehow corrupts things.

[Extension Host] TypeError: Expected signal to be an instanceof AbortSignal
	at new B (/Users/chrmarti/Development/repos/vscode-azure-account/dist/extension.js:364:12277)
	at /Users/chrmarti/Development/repos/vscode-azure-account/dist/extension.js:364:14625
	at new Promise (<anonymous>)
	at G (/Users/chrmarti/Development/repos/vscode-azure-account/dist/extension.js:364:14589)
	at t.<anonymous> (/Users/chrmarti/Development/repos/vscode-azure-account/dist/extension.js:364:76748)
	at /Users/chrmarti/Development/repos/vscode-azure-account/dist/extension.js:16:1768
	at Object.next (/Users/chrmarti/Development/repos/vscode-azure-account/dist/extension.js:16:1873)
	at /Users/chrmarti/Development/repos/vscode-azure-account/dist/extension.js:16:811
	at new Promise (<anonymous>)
	at a (/Users/chrmarti/Development/repos/vscode-azure-account/dist/extension.js:16:548)
	at t.fetch (/Users/chrmarti/Development/repos/vscode-azure-account/dist/extension.js:364:76672)
	at t.<anonymous> (/Users/chrmarti/Development/repos/vscode-azure-account/dist/extension.js:364:74931)
	at /Users/chrmarti/Development/repos/vscode-azure-account/dist/extension.js:16:1768
	at Object.next (/Users/chrmarti/Development/repos/vscode-azure-account/dist/extension.js:16:1873)
	at a (/Users/chrmarti/Development/repos/vscode-azure-account/dist/extension.js:16:604)
	at processTicksAndRejections (internal/process/task_queues.js:93:5)

@chrmarti
Copy link
Contributor

This appears to be node-fetch/node-fetch#784. Just not throwing the error by manually removing it makes it work. The solution on that issue was to not minify class names. How did you build the VSIX avoiding this issue?

@RMacfarlane
Copy link
Contributor Author

Hmm, I'm just building with vsce package, but I still don't see that in the console

@chrmarti
Copy link
Contributor

What do you get for regex searching for class.*EventTarget in dist/extension.js after compiling with npm run vscode:prepublish? My first match is the minified AbortSignal class:

class i extends r.EventTarget{constructor(){throw super(),new TypeError("AbortSignal cannot be constructed directly")} ...

Its name has been minified to i.

Searching for "AbortSignal" finds me the check that no longer works:

"AbortSignal"!==t.constructor.name)}(a))throw new TypeError("Expected signal to be an instanceof AbortSignal");

Do you have these too? I'd expect so. Maybe you just don't run through this code for some reason?

@RMacfarlane
Copy link
Contributor Author

Ah, thanks, I do see the same minification in the output, so I must just not be hitting that code path for some reason.

I pushed a change to turn off minification, which unfortunately doubles the size of the .js file to 4MB, but retains the class name.

@RMacfarlane RMacfarlane merged commit 0fa0989 into master Jun 26, 2020
@RMacfarlane RMacfarlane deleted the rmacfarlane/sdkUpdates branch June 26, 2020 19:59
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants