Repository navigation
Treat the enterprise provider registration timeout as unavailable - #9256
Mickael Saidi (MikeFTV) wants to merge 7 commits into
Conversation
CredentialStore.getSession already continues without a session when the github-enterprise provider is not registered, but a host that contributes the provider and registers it only once an enterprise URI is set makes getSession time out instead. Treat that message the same way so GitHub.com sign-in and the Pull Requests view still start.
There was a problem hiding this comment.
🟡 Changes recommended
The credential tests leave real, unawaited GitHub requests running with fabricated tokens, allowing background network and authentication-error handling to spill into later tests.
1 open issue
What changed in this PR
Allows credential initialization to continue when GitHub Enterprise provider registration times out, addressing the activation failure reported in #9254.
Changes:
- Treats the Enterprise registration timeout as provider unavailability while preserving other errors.
- Adds tests for GitHub.com authentication fallback and unrelated-error propagation.
| File | Description |
|---|---|
src/test/github/credentials.test.ts |
Adds fallback and error-propagation tests. |
src/github/credentials.ts |
Groups recognized Enterprise provider errors and handles registration timeouts. |
Review effort: Balanced
| sinon.stub(process, 'env').value({ ...process.env, GITHUB_OAUTH_TOKEN: undefined }); | ||
| credentialStore = new CredentialStore(new MockTelemetry(), new MockExtensionContext()); | ||
| getSession = sinon.stub(vscode.authentication, 'getSession'); | ||
| getSession.withArgs(AuthProvider.github).resolves(createSession('dotcom-session', 'account', defaultScopes)); |
| sinon.stub(process, 'env').value({ ...process.env, GITHUB_OAUTH_TOKEN: undefined }); | ||
| credentialStore = new CredentialStore(new MockTelemetry(), new MockExtensionContext()); | ||
| getSession = sinon.stub(vscode.authentication, 'getSession'); | ||
| getSession.withArgs(AuthProvider.github).resolves(createSession('dotcom-session', 'account', defaultScopes)); |
| sinon.stub(process, 'env').value({ ...process.env, GITHUB_OAUTH_TOKEN: undefined }); | ||
| credentialStore = new CredentialStore(new MockTelemetry(), new MockExtensionContext()); | ||
| getSession = sinon.stub(vscode.authentication, 'getSession'); | ||
| getSession.withArgs(AuthProvider.github).resolves(createSession('dotcom-session', 'account', defaultScopes)); |
|
Mickael Saidi (@MikeFTV) please read the following Contributor License Agreement(CLA). If you agree with the CLA, please reply with the following information.
Contributor License AgreementContribution License AgreementThis Contribution License Agreement (“Agreement”) is agreed to by the party signing below (“You”),
|
| sinon.stub(process, 'env').value({ ...process.env, GITHUB_OAUTH_TOKEN: undefined }); | ||
| credentialStore = new CredentialStore(new MockTelemetry(), new MockExtensionContext()); | ||
| getSession = sinon.stub(vscode.authentication, 'getSession'); | ||
| getSession.withArgs(AuthProvider.github).resolves(createSession('dotcom-session', 'account', defaultScopes)); |

Why
Since 0.168.0
CredentialStore.doCreatelooks up agithub-enterprisesession on every activation.getSessionalready carries on without a session when the host saysNo authentication provider 'github-enterprise' is currently registered., but #9254 reports a host (Cursor) that contributes the provider incontributes.authenticationand registers it only whengithub-enterprise.uriis set. Therevscode.authentication.getSessionwaits and then throwsTimed out waiting for authentication provider 'github-enterprise' to register., which is rethrown, so activation stops before the tree data provider exists.What changes
getSessionnow treats that timeout message like the "not registered" one for the enterprise provider only: it logs the existing "unavailable" line and returns no session, so the GitHub.com lookup that follows indoCreatestill runs. The two messages sit in one constant next to the class. Any other error from the enterprise lookup, including a timeout message that names another provider, is still thrown.The message check is by text because the extension API gives no error code for this. The extension still waits out the provider timeout (about five seconds in the report) on such a host; skipping the lookup when no enterprise URI is configured, as 0.166.1 did, would avoid the wait, but I kept to the smaller change that the issue lists as one of its two options. Happy to switch if you prefer that one.
Refs #9254. I could not run the reporter's host, so I am not claiming the exact startup failure is gone, only that the code path it hits now continues.
Tests
credentials.test.ts, newGitHub Enterprise provider that is not registeredblock: for each of the two messages,create()resolves{ canceled: false, unavailable: false }with GitHub.com authenticated and enterprise not; a different enterprise error and a timeout message naming thegithubprovider are still rejected.Timed out waiting for authentication provider 'github-enterprise' to register.; the "not registered" case and the rejection case pass either way.npx eslint src/github/credentials.tsandnode build/hygiene.js: no errors.npm testdownloads and launches VS Code, and this machine has no display). I compiled withtsc -p tsconfig.test.jsonand rancredentials.test.jsunder mocha with a stand-invscodemodule: the three new tests pass, and 7 older tests in the file fail only because they stubvscode.authentication.getAccounts, which the stand-in lacks.tscalso reports one error insrc/github/pullRequestOverview.ts(isAgentManaged), which is onmainwithout my change.