fix: wait for extension relay tab reconnects (#32461) (thanks @AaronWander)

This commit is contained in:
Peter Steinberger
2026-03-08 19:11:33 +00:00
parent bcb0d1b8b4
commit 0692f71c6f
3 changed files with 38 additions and 4 deletions

View File

@@ -151,4 +151,29 @@ describe("browser server-context ensureTabAvailable", () => {
vi.useRealTimers();
}
});
it("still fails after the extension-tab grace window expires", async () => {
vi.useFakeTimers();
try {
const responses = [
[{ id: "A", type: "page", url: "https://a.example", webSocketDebuggerUrl: "ws://x/a" }],
[{ id: "A", type: "page", url: "https://a.example", webSocketDebuggerUrl: "ws://x/a" }],
...Array.from({ length: 20 }, () => []),
];
stubChromeJsonList(responses);
const state = makeBrowserState();
const ctx = createBrowserRouteContext({ getState: () => state });
const chrome = ctx.forProfile("chrome");
await chrome.ensureTabAvailable();
const pending = expect(chrome.ensureTabAvailable()).rejects.toThrow(
/no attached Chrome tabs/i,
);
await vi.advanceTimersByTimeAsync(3_500);
await pending;
} finally {
vi.useRealTimers();
}
});
});

View File

@@ -65,7 +65,9 @@ describe("git commit resolution", () => {
const repoHead = execFileSync("git", ["rev-parse", "--short=7", "HEAD"], {
cwd: repoRoot,
encoding: "utf-8",
}).trim();
})
.trim()
.slice(0, 7);
const temp = await makeTempDir("git-commit-cwd");
const otherRepo = path.join(temp, "other");
@@ -81,7 +83,9 @@ describe("git commit resolution", () => {
const otherHead = execFileSync("git", ["rev-parse", "--short=7", "HEAD"], {
cwd: otherRepo,
encoding: "utf-8",
}).trim();
})
.trim()
.slice(0, 7);
process.chdir(otherRepo);
const { resolveCommitHash } = await import("./git-commit.js");
@@ -95,7 +99,9 @@ describe("git commit resolution", () => {
const repoHead = execFileSync("git", ["rev-parse", "--short=7", "HEAD"], {
cwd: repoRoot,
encoding: "utf-8",
}).trim();
})
.trim()
.slice(0, 7);
const { resolveCommitHash } = await import("./git-commit.js");
const entryModuleUrl = pathToFileURL(path.join(repoRoot, "src", "entry.ts")).href;
@@ -161,7 +167,9 @@ describe("git commit resolution", () => {
const repoHead = execFileSync("git", ["rev-parse", "--short=7", "HEAD"], {
cwd: repoRoot,
encoding: "utf-8",
}).trim();
})
.trim()
.slice(0, 7);
const { resolveCommitHash } = await import("./git-commit.js");