Skip to content

Unable to upload 10MB files using Functions #71

@pedromassango

Description

@pedromassango

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/std@0.182.0/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/oak@v11.1.0/mod.ts?s=FormDataReadOptions
    maxSize: maxFileSizeForFreeVersion * MB,
    maxFileSize: maxFileSizeForFreeVersion * MB,
    bufferSize: maxFileSizeForFreeVersion * MB
  });
  console.log('PARSING FILE - ERROR')

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

      pFad - Phonifier reborn

      Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

      Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


      Alternative Proxies:

      Alternative Proxy

      pFad Proxy

      pFad v3 Proxy

      pFad v4 Proxy