oak
oak copied to clipboard
Bug: Importing Oak inside a Web Worker prevents the Worker from working at all
$ deno --version deno 1.15.3 (release, x86_64-pc-windows-msvc) v8 9.5.172.19 typescript 4.4.2
main.ts
const worker = new Worker(
new URL("./worker.ts", import.meta.url).href,
{
type: "module",
deno: {
namespace: true,
},
},
);
worker.postMessage(null);
worker.ts
import * as Oak from "https://deno.land/x/[email protected]/mod.ts";
console.assert(Boolean(Oak));
self.onmessage = () => {
console.log("This is never printed as long as the import is present.");
};
self.onerror = (e) => {
console.error(e);
}
Expected output:
This is never printed as long as the import is present..
Actual output:
$ deno run --unstable --no-check --allow-all main.ts
Instead of the expected output nothing is printed and it seems the worker is stuck / not properly started.
Motivation: I have a project where Oak is imported in a deps.ts file that contains all dependencies in the project. Hence, it is also included within the worker to consume other dependencies.
This issue is still present using the latest version of Oak (1.10.0) and Deno (1.17.1)