Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Worker on deno deploy #171

Open
hapaxlife opened this issue Feb 12, 2022 · 5 comments
Open

Worker on deno deploy #171

hapaxlife opened this issue Feb 12, 2022 · 5 comments

Comments

@hapaxlife
Copy link

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
Copy link

Same thing for me

I cannot hash user passwords server side for now

@ninjinskii
Copy link

Gonna look for this synchronous version by then

@hapaxlife
Copy link
Author

hapaxlife commented May 25, 2022

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
Copy link

ttogola commented Aug 4, 2022

@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
Copy link

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)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants