Shared array buffer missing error (#1518)

Improve error reporting around SharedArrayBuffer
This commit is contained in:
Andrea Giammarchi
2023-06-09 20:51:51 +02:00
committed by GitHub
parent 818614b798
commit bb364b0524
2 changed files with 14 additions and 1 deletions

View File

@@ -9,6 +9,19 @@ import coincident from "coincident/structured";
import { registry } from "../runtimes.js";
import { getRuntime, getRuntimeID } from "../loader.js";
// bails out out of the box with a native/meaningful error
// in case the SharedArrayBuffer is not available
try {
new SharedArrayBuffer(4);
} catch (_) {
throw new Error(
[
"Unable to use SharedArrayBuffer due insecure environment.",
"Please read requirements in MDN: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/SharedArrayBuffer#security_requirements",
].join("\n"),
);
}
let engine, run, runtimeEvent;
const add = (type, fn) => {
addEventListener(

View File

@@ -50,6 +50,6 @@
"coincident": "^0.2.3"
},
"worker": {
"blob": "sha256-m8uF2bNB691FtVIpuDfAT/avUolqZRQwO9tD3r88+6A="
"blob": "sha256-LhH/RqqHJJNjYkIoMjALOt1xdneBHAyy+jgMKO07Mx0="
}
}