deploy_feedback icon indicating copy to clipboard operation
deploy_feedback copied to clipboard

[Bug]: Worker is not defined

Open krysalead opened this issue 9 months ago • 1 comments

Problem description

I am creating workers for slow background tasks locally Deno is working properly. When deploying it says "Worker is not defined" Do I have to do something special to activate Workers for deployment?

Steps to reproduce

// main.ts const worker = new Worker(new URL("./worker.ts", import.meta.url).href, { type: "module", }); // worker.ts self.onmessage = async (event: MessageEvent) => { const { url, id } = event.data; logger.info(Worker started for ${id} self.postMessage({ id }); };

Expected behavior

No error during deployment

Environment

Deno: deno 2.1.9 (stable, release, x86_64-unknown-linux-gnu) v8 13.0.245.12-rusty typescript 5.6.2 System WSL: 5.15.167.4-microsoft-standard-WSL2 #1 SMP Tue Nov 5 00:21:55 UTC 2024 x86_64 x86_64 x86_64 GNU/Linux

Possible solution

No response

Additional context

No response

krysalead avatar Feb 25 '25 20:02 krysalead

I don't think workers are supported but if you have background work I think you may be able to accomplish what you're looking for instead using Deno KV and using the queue functionality:

https://docs.deno.com/deploy/kv/tutorials/schedule_notification/

justinmchase avatar Mar 01 '25 17:03 justinmchase