denoland / deploy_feedback

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

Worker on deno deploy #171

Open hapaxlife opened 2 years ago

hapaxlife commented 2 years ago

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/bcrypt@v0.3.0/mod.ts";

console.log(  bcrypt.hashSync("test")) // OK
console.log( await bcrypt.hash("test")) // KO
ninjinskii commented 2 years ago

Same thing for me

I cannot hash user passwords server side for now

ninjinskii commented 2 years ago

Gonna look for this synchronous version by then

hapaxlife commented 2 years ago

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/bcrypt@v0.3.0/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,
});
ttogola commented 2 years ago

@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.

lionel-rowe commented 6 months ago

Closed as fixed? Or because OP doesn't need it any more? Assuming workers still aren't supported, I think there should be an open tracking issue for this (unless it's wontfix forever)