denoland / deploy_feedback

For reporting issues with Deno Deploy
https://deno.com/deploy
74 stars 5 forks source link

ReferenceError: Worker is not defined #630

Open omararturo opened 8 months ago

omararturo commented 8 months ago

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/std@0.218.0/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);
};

image