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

Unable to upload 10MB files using Functions #71

Open
2 tasks done
pedromassango opened this issue Sep 9, 2023 · 0 comments
Open
2 tasks done

Unable to upload 10MB files using Functions #71

pedromassango opened this issue Sep 9, 2023 · 0 comments
Labels
bug Something isn't working

Comments

@pedromassango
Copy link

pedromassango commented Sep 9, 2023

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

Getting error while trying to upload heavy File using Edge Functions. It works fine with files <=5 MB and it fails with files of around 9/10+ MBs.

To Reproduce

Steps to reproduce the behavior, please provide code snippets or a repository:

  1. Create a function that expects a Files
  2. run it and pass in a File (you can use Postman)
  3. See error

Expected behavior

File is received

Current behavior: crash

[Info] PARSING FILE...

CPU time limit reached. isolate: 3328699061268672774
event loop error: Uncaught Error: execution terminated
Error in worker connection: error writing a body to connection: Broken pipe (os error 32)
failed to send request to user worker: connection error: Connection reset by peer (os error 104)
InvalidWorkerResponse: user worker failed to respond
    at async UserWorker.fetch (ext:sb_user_workers/user_workers.js:52:15)
    at async Server.<anonymous> (file:///home/deno/main/index.ts:123:12)
    at async Server.#respond (https://deno.land/[email protected]/http/server.ts:220:18) {
  name: "InvalidWorkerResponse"
}
event loop error: TypeError: request body receiver not connected (request closed)
    at async Object.write (ext:deno_web/06_streams.js:954:9)
Error in worker connection: error writing a body to connection: Broken pipe (os error 32)
request failed (uri: "/create_chat" reason: hyper::Error(Io, Os { code: 104, kind: ConnectionReset, message: "Connection reset by peer" }))

System information

  • OS: [macOS]
  • Version of supabase-js: [2.4.0]

Piece of code to extract file from formData:

  console.log('PARSING FILE...')
  const body = ctx.request.body({ type: "form-data" });
  const maxFileSizeForFreeVersion = 15;

  const formData = await body.value.read({
    // Need to set the maxSize so files will be stored in memory.
    // This is necessary as Edge Functions don't have disk write access.
    // We are setting the max size as 10MB (an Edge Function has a max memory limit of 150MB)
    // For more config options, check: https://deno.land/x/[email protected]/mod.ts?s=FormDataReadOptions
    maxSize: maxFileSizeForFreeVersion * MB,
    maxFileSize: maxFileSizeForFreeVersion * MB,
    bufferSize: maxFileSizeForFreeVersion * MB
  });
  console.log('PARSING FILE - ERROR')
@pedromassango pedromassango added the bug Something isn't working label Sep 9, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

1 participant