Skip to content

Unable to deploy function #3426

@FaludaAndIce

Description

@FaludaAndIce

Bug report

  • I confirm this is a bug with Supabase, not with my own application.
  • I confirm I have searched the Docs, GitHub Discussions, and Discord.

Describe the bug

The Supabase CLI consistently fails to deploy an Edge Function that imports modules from Deno's standard library (std/server) and @supabase/supabase-js, reporting a "Module not found" error for the standard library module, even when a correctly formatted deno.json import map is present in the function's directory and explicitly referenced in config.toml or via the --import-map flag.

To Reproduce

Steps to reproduce the behavior:

  1. Initialize a Supabase project and create a new Edge Function named check-user-existence using the Supabase CLI.

  2. Replace the contents of supabase/functions/check-user-existence/index.ts with the following code:

    // Setup type definitions for built-in Supabase Runtime APIs
    import "jsr:@supabase/functions-js/edge-runtime.d.ts";
    
    import { serve } from 'std/server';
    import { createClient } from '@supabase/supabase-js';
    
    const supabaseUrl = Deno.env.get('SUPABASE_URL')!;
    const supabaseServiceKey = Deno.env.get('SERVICE_ROLE_KEY')!;
    
    const supabaseClient = createClient(supabaseUrl, supabaseServiceKey, {
      auth: {
        persistSession: false,
      },
    });
    
    serve(async (req: Request) => {
      if (req.method !== 'POST') {
        return new Response('Method Not Allowed', { status: 405 });
      }
      try {
        const { email }: { email?: string } = await req.json();
        if (!email) {
          return new Response(JSON.stringify({ error: 'Email is required' }), { status: 400, headers: { 'Content-Type': 'application/json' } });
        }
        const { data, error } = await supabaseClient.auth.admin.getUserByEmail(email);
        const exists = data !== null;
        return new Response(JSON.stringify({ exists }), { headers: { 'Content-Type': 'application/json' } });
      } catch (error) {
        return new Response(JSON.stringify({ error: 'Internal Server Error' }), { status: 500, headers: { 'Content-Type': 'application/json' } });
      }
    });
  3. Create a deno.json file in the supabase/functions/check-user-existence directory with the following content:

    {
      "imports": {
        "std/": "[https://deno.land/std@1.42.0/](https://deno.land/std@1.42.0/)",
        "@supabase/supabase-js": "[https://esm.supabase.com/supabase-js@2](https://esm.supabase.com/supabase-js@2)"
      }
    }
  4. Ensure your config.toml file in the project root has the following configuration for the function:

    [functions.check-user-existence]
    enabled = true
    verify_jwt = true
    import_map = "./supabase/functions/check-user-existence/deno.json"
    entrypoint = "./supabase/functions/check-user-existence/index.ts"
  5. Attempt to deploy the function using the command: supabase functions deploy check-user-existence from the project root.

  6. Observe the error: Error: failed to create the graph Caused by: Module not found "https://deno.land/std@1.42.0/server/mod.ts" ... Relative import path "std/server" not prefixed with / or ./ or ../ and not in import map ...

Expected behavior

The Edge Function should be bundled and deployed successfully, resolving the std/server and @supabase/supabase-js modules using the deno.json import map.

Screenshots

Screenshot:
Image

Debug:

navishanmendis@Navishans-Laptop MahiBase % supabase functions deploy check-user-existence --debug
Supabase CLI 2.20.3
2025/03/26 22:43:55 DNS Start: {Host:api.supabase.com}
2025/03/26 22:43:55 DNS Done: {Addrs:[{IP:2606:4700:10::6816:3fc Zone:} {IP:2606:4700:10::6816:2fc Zone:} {IP:2606:4700:10::ac43:17c7 Zone:} {IP:172.67.23.199 Zone:} {IP:104.22.2.252 Zone:} {IP:104.22.3.252 Zone:}] Err:<nil> Coalesced:false}
2025/03/26 22:43:55 Connect Start: tcp [2606:4700:10::6816:3fc]:443
2025/03/26 22:43:55 Connect Done: tcp [2606:4700:10::6816:3fc]:443
2025/03/26 22:43:55 TLS Start
2025/03/26 22:43:55 TLS Done: {Version:772 HandshakeComplete:true DidResume:false CipherSuite:4865 NegotiatedProtocol:h2 NegotiatedProtocolIsMutual:true ServerName:api.supabase.com PeerCertificates:[0x140001ea608 0x140001eac08 0x140001eb808] VerifiedChains:[[0x1400035c008 0x1400035c608 0x1400035cc08]] SignedCertificateTimestamps:[] OCSPResponse:[48 130 1 20 10 1 0 160 130 1 13 48 130 1 9 6 9 43 6 1 5 5 7 48 1 1 4 129 251 48 129 248 48 129 158 162 22 4 20 144 119 146 53 103 196 255 168 204 169 230 123 217 128 121 123 204 147 249 56 24 15 50 48 50 53 48 51 50 49 49 50 51 48 50 50 90 48 115 48 113 48 73 48 9 6 5 43 14 3 2 26 5 0 4 20 185 190 213 241 166 30 64 178 65 150 176 194 158 126 26 157 139 252 181 32 4 20 144 119 146 53 103 196 255 168 204 169 230 123 217 128 121 123 204 147 249 56 2 16 5 63 222 170 28 52 166 77 14 155 138 65 196 91 40 38 128 0 24 15 50 48 50 53 48 51 50 49 49 50 51 48 50 50 90 160 17 24 15 50 48 50 53 48 51 50 56 49 49 51 48 50 49 90 48 10 6 8 42 134 72 206 61 4 3 2 3 73 0 48 70 2 33 0 212 178 27 172 107 236 8 249 174 44 3 37 29 223 74 33 199 2 198 88 63 23 36 92 244 143 17 77 137 25 12 41 2 33 0 252 59 229 91 41 228 181 72 41 209 19 44 143 52 69 137 109 144 39 254 213 45 171 202 225 143 135 171 203 240 94 64] TLSUnique:[] ECHAccepted:false ekm:0x10235c130 testingOnlyDidHRR:false testingOnlyCurveID:29}
2025/03/26 22:43:55 Sent Header: :authority [api.supabase.com]
2025/03/26 22:43:55 Sent Header: :method [GET]
2025/03/26 22:43:55 Sent Header: :path [/v1/projects/orevukenenlhkevnxiav/functions]
2025/03/26 22:43:55 Sent Header: :scheme [https]
2025/03/26 22:43:55 Sent Header: user-agent [SupabaseCLI/2.20.3]
2025/03/26 22:43:55 Sent Header: authorization [Bearer sbp_86078ec1a88a5fae6bd4675c558f09892e57f59f]
2025/03/26 22:43:55 Sent Header: accept-encoding [gzip]
2025/03/26 22:43:55 Send Done
2025/03/26 22:43:55 Recv First Byte
Bundling Function: check-user-existence
2025/03/26 22:43:55 Sent Header: Host [api.moby.localhost]
2025/03/26 22:43:55 Sent Header: User-Agent [Docker-Client/unknown-version (darwin)]
2025/03/26 22:43:55 Send Done
2025/03/26 22:43:55 Recv First Byte
2025/03/26 22:43:55 Sent Header: Host [api.moby.localhost]
2025/03/26 22:43:55 Sent Header: User-Agent [Docker-Client/unknown-version (darwin)]
2025/03/26 22:43:55 Sent Header: Content-Length [265]
2025/03/26 22:43:55 Sent Header: Content-Type [application/json]
2025/03/26 22:43:55 Send Done
2025/03/26 22:43:55 Recv First Byte
2025/03/26 22:43:55 Sent Header: Host [api.moby.localhost]
2025/03/26 22:43:55 Sent Header: User-Agent [Docker-Client/unknown-version (darwin)]
2025/03/26 22:43:55 Sent Header: Content-Length [131]
2025/03/26 22:43:55 Sent Header: Content-Type [application/json]
2025/03/26 22:43:55 Send Done
2025/03/26 22:43:55 Recv First Byte
2025/03/26 22:43:55 Sent Header: Host [api.moby.localhost]
2025/03/26 22:43:55 Sent Header: User-Agent [Docker-Client/unknown-version (darwin)]
2025/03/26 22:43:55 Sent Header: Content-Length [2290]
2025/03/26 22:43:55 Sent Header: Content-Type [application/json]
2025/03/26 22:43:55 Send Done
2025/03/26 22:43:55 Recv First Byte
2025/03/26 22:43:55 Sent Header: Host [api.moby.localhost]
2025/03/26 22:43:55 Sent Header: User-Agent [Docker-Client/unknown-version (darwin)]
2025/03/26 22:43:55 Sent Header: Content-Length [0]
2025/03/26 22:43:55 Send Done
2025/03/26 22:43:55 Recv First Byte
2025/03/26 22:43:55 Sent Header: Host [api.moby.localhost]
2025/03/26 22:43:55 Sent Header: User-Agent [Docker-Client/unknown-version (darwin)]
2025/03/26 22:43:55 Send Done
2025/03/26 22:43:55 Recv First Byte
DEBUG Opening cache /root/.cache/deno/dep_analysis_cache_v1...
DEBUG Opening cache /root/.cache/deno/node_analysis_cache_v1...
DEBUG FileFetcher::fetch_no_follow_with_options - specifier: file:///Users/navishanmendis/Documents/Projects/MahiBase/supabase/functions/check-user-existence/index.ts
DEBUG Specifier "jsr:@supabase/functions-js/edge-runtime.d.ts" was not mapped in import map.
DEBUG Specifier "std/server" was not mapped in import map.
DEBUG FileFetcher::fetch_no_follow_with_options - specifier: https://esm.supabase.com/supabase-js@2
DEBUG FileFetcher::fetch_remote_no_follow - specifier: https://esm.supabase.com/supabase-js@2
Download https://esm.supabase.com/supabase-js@2
DEBUG starting new connection: https://esm.supabase.com/
DEBUG FileFetcher::fetch_no_follow_with_options - specifier: https://jsr.io/@supabase/functions-js/meta.json
DEBUG FileFetcher::fetch_remote_no_follow - specifier: https://jsr.io/@supabase/functions-js/meta.json
Download https://jsr.io/@supabase/functions-js/meta.json
DEBUG starting new connection: https://jsr.io/
DEBUG Import 'https://esm.supabase.com/supabase-js@2' failed: error sending request for url (https://esm.supabase.com/supabase-js@2). Retrying...
DEBUG No cached session for DnsName("jsr.io")
DEBUG Not resuming any session
DEBUG Using ciphersuite TLS13_AES_256_GCM_SHA384
DEBUG Not resuming
DEBUG TLS1.3 encrypted extensions: [ServerNameAck, Protocols([ProtocolName(6832)])]
DEBUG ALPN protocol is Some(b"h2")
DEBUG starting new connection: https://esm.supabase.com/
DEBUG FileFetcher::fetch_cached_no_follow - specifier: https://jsr.io/@supabase/functions-js/meta.json
DEBUG FileFetcher::fetch_no_follow_with_options - specifier: https://jsr.io/@supabase/functions-js/2.4.4_meta.json
DEBUG FileFetcher::fetch_remote_no_follow - specifier: https://jsr.io/@supabase/functions-js/2.4.4_meta.json
Download https://jsr.io/@supabase/functions-js/2.4.4_meta.json
DEBUG FileFetcher::fetch_no_follow_with_options - specifier: https://jsr.io/@supabase/functions-js/2.4.4/src/edge-runtime.d.ts
DEBUG FileFetcher::fetch_remote_no_follow - specifier: https://jsr.io/@supabase/functions-js/2.4.4/src/edge-runtime.d.ts
DEBUG FileFetcher::fetch_cached_no_follow - specifier: https://jsr.io/@supabase/functions-js/2.4.4/src/edge-runtime.d.ts
Error: failed to create the graph

Caused by:
Relative import path "std/server" not prefixed with / or ./ or ../ and not in import map from "file:///Users/navishanmendis/Documents/Projects/MahiBase/supabase/functions/check-user-existence/index.ts"
at file:///Users/navishanmendis/Documents/Projects/MahiBase/supabase/functions/check-user-existence/index.ts:4:23
2025/03/26 22:43:55 Sent Header: Host [api.moby.localhost]
2025/03/26 22:43:55 Sent Header: User-Agent [Docker-Client/unknown-version (darwin)]
2025/03/26 22:43:55 Send Done
2025/03/26 22:43:55 Recv First Byte
error running container: exit 1

System information

  • OS: macOS Sonoma 14.4.1
  • Browser (if applies): N/A
  • Version of supabase-js: (Implicitly used by the Edge Function runtime)
  • Version of Node.js: v20.11.0
  • Version of Supabase CLI: 2.20.3

Additional context

I have tried numerous variations of the deno.json file (including explicit mapping of std/server/mod.ts), using the --import-map flag directly in the deploy command, and reinstalling the Supabase CLI. The issue persists across all attempts. The CLI seems unable to correctly load or utilize the deno.json import map to resolve the Deno standard library modules. The @supabase/functions-js/edge-runtime.d.ts import also doesn't seem to be recognized as being in the import map.

Running with --debug shows lines like:
DEBUG Specifier "std/server" was not mapped in import map.
DEBUG Specifier "jsr:@supabase/functions-js/edge-runtime.d.ts" was not mapped in import map.

This suggests the import map is not being processed correctly during the graph creation phase of the deployment.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions