Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions patches/@wp-playground+cli+3.1.46.patch
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ index 93b7099..65f76be 100644
}
process.on("unhandledRejection", (r) => {
S.error("Unhandled rejection:", r);
+ if (r instanceof WebAssembly.RuntimeError && String(r.stack).includes("php.wasm"))
+ if (r?.name === "RuntimeError" && String(r.stack).includes("php.wasm"))
+ throw r;
});
const i = new _(), [c, p] = y(
Expand All @@ -19,7 +19,7 @@ index fb79a59..77ddb67 100644
}
process.on("unhandledRejection", (r) => {
E.error("Unhandled rejection:", r);
+ if (r instanceof WebAssembly.RuntimeError && String(r.stack).includes("php.wasm"))
+ if (r?.name === "RuntimeError" && String(r.stack).includes("php.wasm"))
+ throw r;
});
const i = new m(), [h, u] = k(
Expand Down
4 changes: 3 additions & 1 deletion patches/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,9 @@ contains the same change.

`@wp-playground+cli+3.1.46.patch` makes blueprint worker threads rethrow fatal
`WebAssembly.RuntimeError` rejections originating from `php.wasm` after logging
them. Other unhandled rejections retain the released CLI's log-only behavior.
them. Detection uses the error name because PHP-WASM errors may cross JavaScript
realm boundaries where `instanceof` is false. Other unhandled rejections retain
the released CLI's log-only behavior.
Without this narrow terminalization, a poisoned PHP-WASM worker remains alive
and leaves the parent request pending until the recipe timeout. Remove the patch
after the Playground CLI ships the same worker terminalization behavior.
3 changes: 2 additions & 1 deletion tests/playground-worker-runtime-rejection.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,14 @@ const preloadPath = join(root, "reject-on-command.mjs")

await writeFile(preloadPath, `
import { parentPort } from "node:worker_threads"
import { runInNewContext } from "node:vm"
parentPort?.on("message", (message) => {
if (message === "wp-codebox-trigger-non-wasm-rejection") {
Promise.reject(new Error("ordinary worker rejection"))
setTimeout(() => parentPort?.postMessage("wp-codebox-worker-survived"), 25)
}
if (message === "wp-codebox-trigger-php-wasm-rejection") {
const error = new WebAssembly.RuntimeError("null function or function signature mismatch")
const error = runInNewContext('new WebAssembly.RuntimeError("null function or function signature mismatch")')
error.stack = "RuntimeError: null function or function signature mismatch\\n at php.wasm.zif_mysqli_poll (wasm://wasm/php.wasm-05996276:wasm-function[12986]:0x9949a8)"
Promise.reject(error)
}
Expand Down