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

InvalidWorkerCreation: worker boot error #457

Open
groksrc opened this issue Feb 8, 2024 · 3 comments
Open

InvalidWorkerCreation: worker boot error #457

groksrc opened this issue Feb 8, 2024 · 3 comments

Comments

@groksrc
Copy link
Contributor

groksrc commented Feb 8, 2024

Describe the bug

This change introduces an import error with respect to the crypto library when conntecting to secured instances with TLS: 51e34b2

When attempting to instantiate a new instance of the postgres client a worker boot error is thrown:

Uncaught SyntaxError: The requested module './_wasm/mod.ts' does not provide an export named 'DigestAlgorithm'
    at https://deno.land/[email protected]/crypto/crypto.ts:108:14
InvalidWorkerCreation: worker boot error
    at async Function.create (ext:sb_user_workers/user_workers.js:84:15)
    at async Server.<anonymous> (file:///home/deno/main/index.ts:110:24)
    at async Server.#respond (https://deno.land/[email protected]/http/server.ts:220:24)

To Reproduce

Steps to reproduce the behavior:

With a new supabase project:

  • $ supabase functions new test

  • Modify the file test/index.ts

// ./supabase/functions/test/index.ts
import { serve } from "https://deno.land/[email protected]/http/server.ts"
import * as postgres from "https://deno.land/x/postgres/mod.ts"

const databaseUrl = Deno.env.get('SUPABASE_DB_URL')

serve(async (req) => {
  const client = new postgres.Client(databaseUrl);
  client.connect();
  const data = {
    message: `Booted!`,
  }

  return new Response(
    JSON.stringify(data),
    { headers: { "Content-Type": "application/json" } },
  )
})
  • Start the endpoint
    $ supabase functions serve test

  • Get the auth token for the next command, both the anon key and service_role key will work
    $ supabase status

  • Call the endpoint
    $ curl -v http://localhost:54321/functions/v1/test --header 'Authorization: Bearer <anon or service_role key>'

Expected behavior

An http 200 response is returned with the content:
{ "message": "Booted!" }

Actual Behavior

Server
$ supabase functions serve test
Setting up Edge Functions runtime...
Download https://deno.land/[email protected]/http/server.ts
Download https://deno.land/x/[email protected]/index.ts
Download https://deno.land/[email protected]/async/mod.ts
Download https://deno.land/x/[email protected]/jwe/compact/decrypt.ts
Download https://deno.land/x/[email protected]/jwe/flattened/decrypt.ts
Download https://deno.land/x/[email protected]/jwe/general/decrypt.ts
Download https://deno.land/x/[email protected]/jwe/general/encrypt.ts
Download https://deno.land/x/[email protected]/jws/compact/verify.ts
Download https://deno.land/x/[email protected]/jws/flattened/verify.ts
Download https://deno.land/x/[email protected]/jws/general/verify.ts
Download https://deno.land/x/[email protected]/jwt/verify.ts
Download https://deno.land/x/[email protected]/jwt/decrypt.ts
Download https://deno.land/x/[email protected]/jwe/compact/encrypt.ts
Download https://deno.land/x/[email protected]/jwe/flattened/encrypt.ts
Download https://deno.land/x/[email protected]/jws/compact/sign.ts
Download https://deno.land/x/[email protected]/jws/flattened/sign.ts
Download https://deno.land/x/[email protected]/jws/general/sign.ts
Download https://deno.land/x/[email protected]/jwt/sign.ts
Download https://deno.land/x/[email protected]/jwt/encrypt.ts
Download https://deno.land/x/[email protected]/jwk/thumbprint.ts
Download https://deno.land/x/[email protected]/jwk/embedded.ts
Download https://deno.land/x/[email protected]/jwks/local.ts
Download https://deno.land/x/[email protected]/jwks/remote.ts
Download https://deno.land/x/[email protected]/jwt/unsecured.ts
Download https://deno.land/x/[email protected]/key/export.ts
Download https://deno.land/x/[email protected]/key/import.ts
Download https://deno.land/x/[email protected]/util/decode_protected_header.ts
Download https://deno.land/x/[email protected]/util/decode_jwt.ts
Download https://deno.land/x/[email protected]/util/errors.ts
Download https://deno.land/x/[email protected]/key/generate_key_pair.ts
Download https://deno.land/x/[email protected]/key/generate_secret.ts
Download https://deno.land/x/[email protected]/util/base64url.ts
Download https://deno.land/x/[email protected]/lib/is_object.ts
Download https://deno.land/x/[email protected]/runtime/fetch_jwks.ts
Download https://deno.land/x/[email protected]/runtime/env.ts
Download https://deno.land/x/[email protected]/runtime/base64url.ts
Download https://deno.land/x/[email protected]/runtime/asn1.ts
Download https://deno.land/x/[email protected]/runtime/jwk_to_key.ts
Download https://deno.land/x/[email protected]/lib/buffer_utils.ts
Download https://deno.land/x/[email protected]/runtime/generate.ts
Download https://deno.land/x/[email protected]/runtime/key_to_jwk.ts
Download https://deno.land/x/[email protected]/jwt/produce.ts
Download https://deno.land/x/[email protected]/lib/cek.ts
Download https://deno.land/x/[email protected]/lib/is_disjoint.ts
Download https://deno.land/x/[email protected]/lib/encrypt_key_management.ts
Download https://deno.land/x/[email protected]/lib/validate_crit.ts
Download https://deno.land/[email protected]/async/abortable.ts
Download https://deno.land/[email protected]/async/deadline.ts
Download https://deno.land/[email protected]/async/debounce.ts
Download https://deno.land/[email protected]/async/deferred.ts
Download https://deno.land/[email protected]/async/delay.ts
Download https://deno.land/[email protected]/async/mux_async_iterator.ts
Download https://deno.land/[email protected]/async/pool.ts
Download https://deno.land/[email protected]/async/tee.ts
Download https://deno.land/[email protected]/async/retry.ts
Download https://deno.land/x/[email protected]/runtime/decrypt.ts
Download https://deno.land/x/[email protected]/runtime/zlib.ts
Download https://deno.land/x/[email protected]/lib/decrypt_key_management.ts
Download https://deno.land/x/[email protected]/lib/validate_algorithms.ts
Download https://deno.land/x/[email protected]/lib/jwt_claims_set.ts
Download https://deno.land/x/[email protected]/runtime/verify.ts
Download https://deno.land/x/[email protected]/lib/check_key_type.ts
Download https://deno.land/x/[email protected]/runtime/sign.ts
Download https://deno.land/x/[email protected]/runtime/encrypt.ts
Download https://deno.land/x/[email protected]/lib/iv.ts
Download https://deno.land/x/[email protected]/runtime/webcrypto.ts
Download https://deno.land/x/[email protected]/lib/invalid_key_input.ts
Download https://deno.land/x/[email protected]/runtime/is_key_like.ts
Download https://deno.land/x/[email protected]/runtime/digest.ts
Download https://deno.land/x/[email protected]/runtime/random.ts
Download https://deno.land/x/[email protected]/lib/format_pem.ts
Download https://deno.land/x/[email protected]/runtime/subtle_dsa.ts
Download https://deno.land/x/[email protected]/runtime/check_key_length.ts
Download https://deno.land/x/[email protected]/runtime/get_sign_verify_key.ts
Download https://deno.land/x/[email protected]/lib/check_iv_length.ts
Download https://deno.land/x/[email protected]/runtime/check_cek_length.ts
Download https://deno.land/x/[email protected]/lib/crypto_key.ts
Download https://deno.land/x/[email protected]/runtime/aeskw.ts
Download https://deno.land/x/[email protected]/runtime/ecdhes.ts
Download https://deno.land/x/[email protected]/runtime/pbes2kw.ts
Download https://deno.land/x/[email protected]/runtime/rsaes.ts
Download https://deno.land/x/[email protected]/lib/aesgcmkw.ts
Download https://deno.land/x/[email protected]/lib/epoch.ts
Download https://deno.land/x/[email protected]/lib/secs.ts
Download https://deno.land/x/[email protected]/runtime/timing_safe_equal.ts
Download https://deno.land/x/[email protected]/runtime/subtle_rsaes.ts
Download https://deno.land/x/[email protected]/runtime/bogus.ts
Download https://deno.land/x/[email protected]/lib/check_p2s.ts
Serving functions on http://localhost:54321/functions/v1/<function-name>
serving the request with /home/deno/functions/test
Download https://deno.land/[email protected]/http/server.ts
Download https://deno.land/x/postgres/mod.ts
Download https://deno.land/[email protected]/async/mod.ts
Download https://deno.land/[email protected]/async/abortable.ts
Download https://deno.land/[email protected]/async/deadline.ts
Download https://deno.land/[email protected]/async/debounce.ts
Download https://deno.land/[email protected]/async/deferred.ts
Download https://deno.land/[email protected]/async/delay.ts
Download https://deno.land/[email protected]/async/mux_async_iterator.ts
Download https://deno.land/[email protected]/async/pool.ts
Download https://deno.land/[email protected]/async/tee.ts
Download https://deno.land/[email protected]/async/retry.ts
Warning Implicitly using latest version (v0.17.2) for https://deno.land/x/postgres/mod.ts
Download https://deno.land/x/[email protected]/mod.ts
Download https://deno.land/x/[email protected]/client.ts
Download https://deno.land/x/[email protected]/client/error.ts
Download https://deno.land/x/[email protected]/pool.ts
Download https://deno.land/x/[email protected]/query/transaction.ts
Download https://deno.land/x/[email protected]/connection/connection.ts
Download https://deno.land/x/[email protected]/connection/connection_params.ts
Download https://deno.land/x/[email protected]/query/query.ts
Download https://deno.land/x/[email protected]/utils/utils.ts
Download https://deno.land/x/[email protected]/utils/deferred.ts
Download https://deno.land/x/[email protected]/deps.ts
Download https://deno.land/x/[email protected]/connection/packet.ts
Download https://deno.land/x/[email protected]/connection/message.ts
Download https://deno.land/x/[email protected]/connection/scram.ts
Download https://deno.land/x/[email protected]/connection/message_code.ts
Download https://deno.land/x/[email protected]/connection/auth.ts
Download https://deno.land/x/[email protected]/query/encode.ts
Download https://deno.land/x/[email protected]/query/decode.ts
Download https://deno.land/[email protected]/encoding/base64.ts
Download https://deno.land/[email protected]/encoding/hex.ts
Download https://deno.land/[email protected]/datetime/parse.ts
Download https://deno.land/[email protected]/io/buf_reader.ts
Download https://deno.land/[email protected]/io/buf_writer.ts
Download https://deno.land/[email protected]/bytes/copy.ts
Download https://deno.land/[email protected]/crypto/crypto.ts
Download https://deno.land/[email protected]/async/delay.ts
Download https://deno.land/[email protected]/fmt/colors.ts
Download https://deno.land/[email protected]/path/mod.ts
Download https://deno.land/x/[email protected]/query/oid.ts
Download https://deno.land/x/[email protected]/query/decoders.ts
Download https://deno.land/[email protected]/datetime/_common.ts
Download https://deno.land/[email protected]/path/windows/mod.ts
Download https://deno.land/[email protected]/path/posix/mod.ts
Download https://deno.land/[email protected]/path/constants.ts
Download https://deno.land/[email protected]/path/basename.ts
Download https://deno.land/[email protected]/path/dirname.ts
Download https://deno.land/[email protected]/path/extname.ts
Download https://deno.land/[email protected]/path/format.ts
Download https://deno.land/[email protected]/path/from_file_url.ts
Download https://deno.land/[email protected]/path/is_absolute.ts
Download https://deno.land/[email protected]/path/join.ts
Download https://deno.land/[email protected]/path/normalize.ts
Download https://deno.land/[email protected]/path/parse.ts
Download https://deno.land/[email protected]/path/relative.ts
Download https://deno.land/[email protected]/path/resolve.ts
Download https://deno.land/[email protected]/path/to_file_url.ts
Download https://deno.land/[email protected]/path/to_namespaced_path.ts
Download https://deno.land/[email protected]/path/common.ts
Download https://deno.land/[email protected]/path/separator.ts
Download https://deno.land/[email protected]/path/_interface.ts
Download https://deno.land/[email protected]/path/glob_to_regexp.ts
Download https://deno.land/[email protected]/path/is_glob.ts
Download https://deno.land/[email protected]/path/join_globs.ts
Download https://deno.land/[email protected]/path/normalize_glob.ts
Download https://deno.land/[email protected]/encoding/_util.ts
Download https://deno.land/[email protected]/assert/assert.ts
Download https://deno.land/[email protected]/crypto/_wasm/mod.ts
Download https://deno.land/[email protected]/crypto/_fnv/mod.ts
Download https://deno.land/x/[email protected]/query/array_parser.ts
Download https://deno.land/[email protected]/path/windows/basename.ts
Download https://deno.land/[email protected]/path/windows/constants.ts
Download https://deno.land/[email protected]/path/windows/dirname.ts
Download https://deno.land/[email protected]/path/windows/extname.ts
Download https://deno.land/[email protected]/path/windows/format.ts
Download https://deno.land/[email protected]/path/windows/from_file_url.ts
Download https://deno.land/[email protected]/path/windows/is_absolute.ts
Download https://deno.land/[email protected]/path/windows/join.ts
Download https://deno.land/[email protected]/path/windows/normalize.ts
Download https://deno.land/[email protected]/path/windows/parse.ts
Download https://deno.land/[email protected]/path/windows/relative.ts
Download https://deno.land/[email protected]/path/windows/resolve.ts
Download https://deno.land/[email protected]/path/windows/to_file_url.ts
Download https://deno.land/[email protected]/path/windows/to_namespaced_path.ts
Download https://deno.land/[email protected]/path/windows/common.ts
Download https://deno.land/[email protected]/path/windows/separator.ts
Download https://deno.land/[email protected]/path/windows/glob_to_regexp.ts
Download https://deno.land/[email protected]/path/windows/is_glob.ts
Download https://deno.land/[email protected]/path/windows/join_globs.ts
Download https://deno.land/[email protected]/path/windows/normalize_glob.ts
Download https://deno.land/[email protected]/path/posix/basename.ts
Download https://deno.land/[email protected]/path/posix/constants.ts
Download https://deno.land/[email protected]/path/posix/dirname.ts
Download https://deno.land/[email protected]/path/posix/extname.ts
Download https://deno.land/[email protected]/path/posix/format.ts
Download https://deno.land/[email protected]/path/posix/from_file_url.ts
Download https://deno.land/[email protected]/path/posix/is_absolute.ts
Download https://deno.land/[email protected]/path/posix/join.ts
Download https://deno.land/[email protected]/path/posix/normalize.ts
Download https://deno.land/[email protected]/path/posix/parse.ts
Download https://deno.land/[email protected]/path/posix/relative.ts
Download https://deno.land/[email protected]/path/posix/resolve.ts
Download https://deno.land/[email protected]/path/posix/to_file_url.ts
Download https://deno.land/[email protected]/path/posix/to_namespaced_path.ts
Download https://deno.land/[email protected]/path/posix/common.ts
Download https://deno.land/[email protected]/path/posix/separator.ts
Download https://deno.land/[email protected]/path/posix/glob_to_regexp.ts
Download https://deno.land/[email protected]/path/posix/is_glob.ts
Download https://deno.land/[email protected]/path/posix/join_globs.ts
Download https://deno.land/[email protected]/path/posix/normalize_glob.ts
Download https://deno.land/[email protected]/path/_os.ts
Download https://deno.land/[email protected]/path/_common/common.ts
Download https://deno.land/[email protected]/assert/assertion_error.ts
Download https://deno.land/[email protected]/path/_common/constants.ts
Download https://deno.land/[email protected]/path/_common/strip_trailing_separators.ts
Download https://deno.land/[email protected]/path/_common/assert_path.ts
Download https://deno.land/[email protected]/path/posix/_util.ts
Download https://deno.land/[email protected]/crypto/_wasm/lib/deno_std_wasm_crypto.generated.mjs
Download https://deno.land/[email protected]/path/_common/from_file_url.ts
Download https://deno.land/[email protected]/crypto/_fnv/fnv32.ts
Download https://deno.land/[email protected]/crypto/_fnv/fnv64.ts
Download https://deno.land/[email protected]/path/_common/basename.ts
Download https://deno.land/[email protected]/path/windows/_util.ts
Download https://deno.land/[email protected]/path/_common/normalize_string.ts
Download https://deno.land/[email protected]/path/_common/to_file_url.ts
Download https://deno.land/[email protected]/path/_common/dirname.ts
Download https://deno.land/[email protected]/path/_common/normalize.ts
Download https://deno.land/[email protected]/path/_common/format.ts
Download https://deno.land/[email protected]/path/_common/relative.ts
Download https://deno.land/[email protected]/path/_common/glob_to_reg_exp.ts
Download https://deno.land/[email protected]/crypto/_fnv/util.ts
CPU time used: 197ms
Uncaught SyntaxError: The requested module './_wasm/mod.ts' does not provide an export named 'DigestAlgorithm'
    at https://deno.land/[email protected]/crypto/crypto.ts:108:14
InvalidWorkerCreation: worker boot error
    at async Function.create (ext:sb_user_workers/user_workers.js:84:15)
    at async Server.<anonymous> (file:///home/deno/main/index.ts:110:24)
    at async Server.#respond (https://deno.land/[email protected]/http/server.ts:220:24)
Client
$ curl -v http://localhost:54321/functions/v1/test --header 'Authorization: Bearer <redacted>'
*   Trying [::1]:54321...
* Connected to localhost (::1) port 54321
> GET /functions/v1/test HTTP/1.1
> Host: localhost:54321
> User-Agent: curl/8.4.0
> Accept: */*
> Authorization: Bearer <redacted>
>
< HTTP/1.1 500 Internal Server Error
< Content-Type: application/json
< Content-Length: 50
< Connection: keep-alive
< vary: Accept-Encoding
< date: Thu, 08 Feb 2024 17:10:08 GMT
< X-Kong-Upstream-Latency: 824
< X-Kong-Proxy-Latency: 5
< Via: kong/2.8.1
<
* Connection #0 to host localhost left intact
{"msg":"InvalidWorkerCreation: worker boot error"}%

Additional context

If applicable, add any other context about the problem here.

  • deno-postgres version: v0.17.2
  • deno version: 1.40.3
@bombillazo
Copy link
Collaborator

What version of std are you using in your edge function?

@groksrc
Copy link
Contributor Author

groksrc commented Feb 8, 2024

There are several versions of it that get imported here. [email protected] is the version imported by [email protected] that causes the problem.

[email protected] is imported directly in the test file, that's from the supabase new boilerplate but doesn't have any bearing on this afaict.

[email protected] also gets imported as a dependency from somewhere else.

These are shown in the server console output above.

@bombillazo
Copy link
Collaborator

bombillazo commented Feb 8, 2024

@iuioiua Is this imported correctly in the Deno std library?

https://deno.land/[email protected]/crypto/crypto.ts?source#L112

It is exported in the wasm.mod file, but this is a type. I don't know if the type identifier is required...

I checked all three versions of std, and all have DigestAlgorithm exported as types in the wasm.mod file.

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

2 participants