Skip to content

Functions which import from parent directory fail to deploy using api flag #3467

Open
@sweatybridge

Description

@sweatybridge

Describe the bug
#2533 (comment)

To Reproduce

  1. Create supabase/functions/slug/index.ts
import "jsr:@supabase/functions-js/edge-runtime.d.ts";
import { handler } from "../../../../common/index.ts";

console.log("Hello from Functions!");

Deno.serve(handler);
  1. Create ../common/index.ts
export const handler = async (req) => {
  const { name } = await req.json()
  const data = {
    message: `Hello ${name}!`,
  }

  return new Response(
    JSON.stringify(data),
    { headers: { "Content-Type": "application/json" } },
  )
}
  1. Run supabase functions deploy --use-api and observe error
Uploading asset (update): supabase/functions/slug/index.ts
failed to read file: open ../common/index.ts: invalid argument
Try rerunning the command with --debug to troubleshoot the error.
exit status 1

Expected behavior
Deploying functions that import from parent directory should also work.

The current workaround is to use docker deploy.

System information

  • Version of OS: macOS
  • Version of CLI: v2.22.3

Additional context
Since our bundle API doesn't support parent directories, we have to change the working directory to the actual repo path rather than the current default of ../supabase. This will be a large refactor but also helps with setting more consistent paths in other places like the seed table.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions