node-formidable / formidable

The most used, flexible, fast and streaming parser for multipart form data. Supports uploading to serverless environments, AWS S3, Azure, GCP or the filesystem. Used in production.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Build giving the error in `cloudflare-pages` preset

prvashisht opened this issue · comments

Support plan

  • Which support plan is this issue covered by? (Community, Sponsor, Enterprise): Community
  • Currently blocking your project/work? (yes/no): yes
  • Affecting a production system? (yes/no): no

Context

  • Node.js version: 18.17.1
  • Release Line of Formidable (Legacy, Current, Next): Next
  • Formidable exact version: "^3.5.1"
  • Environment (node, browser, native, OS): node
  • Used with (popular names of modules): Environment - Cloudflare-pages

What are you trying to achieve or the steps to reproduce?

I'm using formidable in my Nuxt 3 project, which is deployed on Cloudflare Pages. Within the project, I have an API in the server directory, and in the API I'm parsing a submitted form. When I create a new form variable with const form = formidable({ multiples: true });, the API throws an error and the initialisation fails with the following error. (It's only breaking in the Cloudflare preset, it works okay locally)

What was the result you got?

A promise rejection was handled asynchronously. This warning occurs when attaching a catch handler to a promise after it rejected. (rejection #1)
[nuxt] [request error] [unhandled] [500] Cannot convert object to primitive value
  at Object.resolve3 [as resolve] (file:.//private/var/folders/2h/krvh_c095nb21j_dkpb8sh1r0000gn/T/tmp-20415-pkuO0PQhrAsi/4ygo2ja85q9.js:15432:46)  
  at new Zn3 (file:.//private/var/folders/2h/krvh_c095nb21j_dkpb8sh1r0000gn/T/tmp-20415-pkuO0PQhrAsi/4ygo2ja85q9.js:15884:25)  
  at formidable$1 (file:.//private/var/folders/2h/krvh_c095nb21j_dkpb8sh1r0000gn/T/tmp-20415-pkuO0PQhrAsi/4ygo2ja85q9.js:16083:31)  
  at file:.//private/var/folders/2h/krvh_c095nb21j_dkpb8sh1r0000gn/T/tmp-20415-pkuO0PQhrAsi/4ygo2ja85q9.js:16095:18  
  at file:.//private/var/folders/2h/krvh_c095nb21j_dkpb8sh1r0000gn/T/tmp-20415-pkuO0PQhrAsi/4ygo2ja85q9.js:19817:31  
  at async Object.handler (file:.//private/var/folders/2h/krvh_c095nb21j_dkpb8sh1r0000gn/T/tmp-20415-pkuO0PQhrAsi/4ygo2ja85q9.js:17656:21)  
  at async file:.//private/var/folders/2h/krvh_c095nb21j_dkpb8sh1r0000gn/T/tmp-20415-pkuO0PQhrAsi/4ygo2ja85q9.js:17733:7  
  at async file:.//private/var/folders/2h/krvh_c095nb21j_dkpb8sh1r0000gn/T/tmp-20415-pkuO0PQhrAsi/4ygo2ja85q9.js:20677:25  
  at async jsonError (file:.//private/var/folders/2h/krvh_c095nb21j_dkpb8sh1r0000gn/T/tmp-20415-pkuO0PQhrAsi/4ygo2ja85q9.js:20912:12)

Now, since I can only see this while running a build preview locally with the Cloudflare preset, the file names are hashed.

What result did you expect?

For the form to be parsed and work as it does locally.

What does the cloudfare preset do ?