deploy_feedback
deploy_feedback copied to clipboard
Worker on deno deploy
We get
ReferenceError: Worker is not defined
when using a Worker
The following code is not working on Deno Deploy but working with Deno
import * as bcrypt from "https://deno.land/x/[email protected]/mod.ts";
console.log( bcrypt.hashSync("test")) // OK
console.log( await bcrypt.hash("test")) // KO
Same thing for me
I cannot hash user passwords server side for now
Gonna look for this synchronous version by then
Deno namespace is available in workers by default see https://deno.com/blog/v1.22
But we still have
ReferenceError: Worker is not defined
at Module.hash (https://deno.land/x/[email protected]/src/main.ts:11:18)
However Deno tell us about worker in their blog
// This worker did NOT have access to the `Deno` namespace.
new Worker(new URL("./worker_without_deno.js", import.meta.url));
// This worker did have access to the `Deno` namespace.
new Worker(new URL("./worker_without_deno.js", import.meta.url), {
deno: true,
});
@hapaxlife I think the source of the confusion is that Deno Deploy does not support all of the APIs that Deno supports. I also ran into this and it took me a while to understand until I found the relevant documentation page.
This Deploy Docs API Reference page states:
Deno Deploy Runtime helps you write web servers in TypeScript/JavaScript using the Web APIs. It's different from Deno but aims to have similar APIs where applicable.
The following Web and Deno APIs are supported on Deno Deploy Runtime.
The Worker API is not listed, so it's not supported. I created an issue to improve the docs in that regard.