fix: contain upstream failures and back off repeated retries

This commit is contained in:
Thomas Durieux committed 2026-10-09 03:48:05 +00:00
1 parent 74fe405e1b
commit 37d10eed20
21 files changed
+511 -108

No files matched your search

+3 -1
View File
@@ -179,13 +179,15 @@ describeMongo("credential access (MongoDB)", function () {
await setCredential(owner.id, "old-token");
await Credential.updateOne({ ownerId: owner._id }, { $set: { updatedAt: new Date(0) } });
const originalFetch = global.fetch;
const oauthConfig = [config.GITHUB_OAUTH_ENABLED, config.CLIENT_ID, config.CLIENT_SECRET];
config.GITHUB_OAUTH_ENABLED = true; config.CLIENT_ID = "fixture-client"; config.CLIENT_SECRET = "fixture-secret";
global.fetch = async (url, options) => {
expect(url).to.include("api.github.com/applications/");
expect(JSON.parse(options.body).access_token).to.equal("old-token");
return { ok: true, json: async () => ({ token: "refreshed-token" }) };
};
try { expect(await repo.getToken()).to.equal("refreshed-token"); }
finally { global.fetch = originalFetch; }
finally { global.fetch = originalFetch; [config.GITHUB_OAUTH_ENABLED, config.CLIENT_ID, config.CLIENT_SECRET] = oauthConfig; }
expect(await getCredentialToken(owner.id)).to.equal("refreshed-token");
expect((await RepoModel.collection.findOne({ _id: repo.model._id })).source.accessToken).to.equal(undefined);
});