Skip to content
Source
Sign inSign up
pingdotgg/t3code

fix(server): preview navigation leaves a page whose script never yields #36365

Mergedjuliusmarmingemerged 3 commits intomain fromrefs/pull/36365/headmerged by juliusmarminge View on GitHub

Showing 6 changed files with 174 additions and 4 deletions (loading 3).

x
0 of 6 viewed, 6 left
68 additions and 0 deletionsapps/desktop/src/preview/Manager.test.tsModified
View file
@@ -746,6 +746,74 @@
​
+ effectIt.effect.each([
+ "navigate",
+ "reload",
+ "goBack",
+ "goForward",
+ "refresh",
+ "hardReload",
+ ] as const)("%s stops a page script that never yields before it navigates", (operation) =>
+ withManager((manager) =>
+ Effect.gen(function* () {
+ const preview = makeFaviconWebContents();
+ // As in Chromium: the hung renderer answers nothing, and a terminate reaches it only
+ // while no navigation is pending.
+ let stopped = false;
+ const probed = yield* Deferred.make<void>();
+ const navigatedAfterStop: Array<boolean> = [];
+ const navigated = () => {
+ navigatedAfterStop.push(stopped);
+ };
+ const sendCommand = async (method: string) => {
+ if (method === "Runtime.evaluate") {
+ Deferred.doneUnsafe(probed, Effect.void);
+ await new Promise(() => {});
+ }
+ if (method === "Runtime.terminateExecution") stopped = true;
+ };