fix(microsoft-foundry): honor Azure device-code lifetime (#113741)

* fix(microsoft-foundry): honor device-code lifetime

Co-authored-by: wangmiao0668000666 <wang.miao86@xydigit.com>

* fix(microsoft-foundry): allow login completion grace

---------

Co-authored-by: wangmiao0668000666 <wang.miao86@xydigit.com>
This commit is contained in:
Peter Steinberger
2026-07-25 08:33:05 -07:00
committed by GitHub
parent 14da8a2523
commit e5999c7316
2 changed files with 6 additions and 5 deletions
+3 -2
View File
@@ -144,7 +144,8 @@ export async function getAccessTokenResultAsync(
) as AzAccessToken;
}
const AZ_LOGIN_TIMEOUT_MS = 5 * 60 * 1000; // 5 minutes
// Entra device codes default to 15 minutes; keep five minutes for az to finish.
const AZ_LOGIN_TIMEOUT_MS = 20 * 60 * 1000;
export async function azLoginDeviceCode(): Promise<void> {
return azLoginDeviceCodeWithOptions({});
@@ -188,7 +189,7 @@ export async function azLoginDeviceCodeWithOptions(params: {
appendOutput("stdout", decoders.stdout.end());
appendOutput("stderr", decoders.stderr.end());
if (result.termination === "timeout") {
throw new Error("az login timed out after 5 minutes");
throw new Error("az login timed out after 20 minutes");
}
if (result.code === 0) {
return;
+3 -3
View File
@@ -2107,7 +2107,7 @@ describe("azLoginDeviceCodeWithOptions utf-8 chunk boundary", () => {
expect(stderrWriteSpy).toHaveBeenCalledWith("😊");
});
it("requests process-tree termination and rejects when az login exceeds 5 minutes", async () => {
it("allows post-auth work after the 15-minute device-code lifetime", async () => {
runCommandWithTimeoutMock.mockResolvedValueOnce({
stdout: "",
stderr: "",
@@ -2120,13 +2120,13 @@ describe("azLoginDeviceCodeWithOptions utf-8 chunk boundary", () => {
const err = await azLoginDeviceCodeWithOptions({}).catch((e: unknown) => e);
expect(err).toBeInstanceOf(Error);
expect((err as Error).message).toBe("az login timed out after 5 minutes");
expect((err as Error).message).toBe("az login timed out after 20 minutes");
expect(runCommandWithTimeoutMock).toHaveBeenCalledWith(
["az", "login", "--use-device-code"],
expect.objectContaining({
killProcessTree: true,
outputCapture: "discard",
timeoutMs: 5 * 60 * 1000,
timeoutMs: 20 * 60 * 1000,
}),
);
});