deploy_feedback
deploy_feedback copied to clipboard
ReferenceError: Worker is not defined
Version: Deno 1.41.1
deployctl deploy --project=example-deploy-worker ./main.ts
//main.ts
const worker = new Worker(import.meta.resolve("./worker.ts"), {
type: "module",
});
worker.postMessage("Hello from main.ts");
//worker.ts
import { delay } from "https://deno.land/[email protected]/async/delay.ts";
// First await: waits for a second, then continues running the module.
await delay(1000);
// The message handler is only set after that 1s delay, so some of the messages
// that reached the worker during that second might have been fired when no
// handler was registered.
self.onmessage = (evt: MessageEvent) => {
console.log(evt.data);
};