Skip to content

Commit ebe35ba

Browse files
committed
fix(devtools): recover stalled WebKit inspector frames
1 parent e782307 commit ebe35ba

3 files changed

Lines changed: 435 additions & 3 deletions

File tree

client/src/features/devtools/DevToolsPanel.test.ts

Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ import { describe, expect, it } from "vitest";
22

33
import {
44
resolveDevToolsTargetSelection,
5+
shouldRemountWebKitFrameForHealth,
56
withSafariAutoTarget,
67
type DevToolsTarget,
78
} from "./DevToolsPanel";
@@ -162,3 +163,61 @@ describe("resolveDevToolsTargetSelection", () => {
162163
});
163164
});
164165
});
166+
167+
describe("shouldRemountWebKitFrameForHealth", () => {
168+
it("remounts stalled WebKit frames within the retry budget", () => {
169+
expect(
170+
shouldRemountWebKitFrameForHealth({
171+
now: 10_000,
172+
recovery: {
173+
frameUrl: "/webkit/target/1",
174+
lastRemountAt: 0,
175+
remountCount: 0,
176+
},
177+
state: "stalled",
178+
}),
179+
).toBe(true);
180+
});
181+
182+
it("does not remount healthy or cooling-down frames", () => {
183+
expect(
184+
shouldRemountWebKitFrameForHealth({
185+
now: 10_000,
186+
recovery: {
187+
frameUrl: "/webkit/target/1",
188+
lastRemountAt: 0,
189+
remountCount: 0,
190+
},
191+
state: "ready",
192+
}),
193+
).toBe(false);
194+
195+
expect(
196+
shouldRemountWebKitFrameForHealth({
197+
cooldownMs: 4_000,
198+
now: 12_000,
199+
recovery: {
200+
frameUrl: "/webkit/target/1",
201+
lastRemountAt: 10_000,
202+
remountCount: 1,
203+
},
204+
state: "stalled",
205+
}),
206+
).toBe(false);
207+
});
208+
209+
it("stops remounting once the retry budget is exhausted", () => {
210+
expect(
211+
shouldRemountWebKitFrameForHealth({
212+
maxRemounts: 3,
213+
now: 20_000,
214+
recovery: {
215+
frameUrl: "/webkit/target/1",
216+
lastRemountAt: 10_000,
217+
remountCount: 3,
218+
},
219+
state: "failed",
220+
}),
221+
).toBe(false);
222+
});
223+
});

0 commit comments

Comments
 (0)