Comments (5)
Looks like .append() method from formdata-node (v2.5.0) is expecting Blob, Stream or Buffer for data (second argument) but @mrbbot/node-fetch is passing a string.
node-fetch: https://github.com/mrbbot/node-fetch/blob/master/src/body.js#L267
formdata-node (branch 2.x): https://github.com/octet-stream/form-data/blob/2.x/lib/FormData.js#L285
from miniflare.
Hey! 👋 For the next major version of Miniflare, the FormData
implementation will come from undici
, which should be more spec-compliant. I'll make sure I've got tests for file uploads too. 👍
from miniflare.
I don't think undici
will solve this problem. The error seem to appear because you pass a file as a string, but the filename
argument can only be used with File
or Blob
. You need to fix the way how you upload files from what you get with busboy
.
Browsers will throw you same error when the third argument is set and the second is a string:
from miniflare.
They don't even have FormData parser in their BodyMixin
as of now: https://github.com/nodejs/undici/blob/68a17943f4d6af5f27d36ab10471f5e8860a1ede/lib/fetch/body.js#L307-L309
The problem can be solved if you just convert files payload into Blob
or File
and set the right arguments for each type of the value. You can just upgrade formdata-node
to latest version or use fetch-blob
(in case if you don't need CJS) to get both of these classes.
For latest formdata-node
you'll also need to include a multipart/form-data
encoder into your node-fetch
fork, such as form-data-encoder
because node-fetch
does not include one in v2 (v3 does and it even will have form-data parser when this PR will be merged)
from miniflare.
Hey! 👋 The first pre-release of Miniflare 2 has just been released, including support for the formdata_parser_supports_files
compatibility flag. Without the flag, uploaded files will be treated as regular string fields. You can find the full changelog here and install it with npm i miniflare@next -D
. Please let me know if you have any other issues, and feel free to ask questions in the #miniflare
channel of the Cloudflare Workers Discord server.
from miniflare.
Related Issues (20)
- Node 21 vitest-environment-miniflare compatibility HOT 1
- [Miniflare 3] Step debugging with multiple workers HOT 2
- Update undici dependency due to vulnerability HOT 1
- [Docs] Miniflare v2 docs removed? HOT 3
- How to migrate Jest unit tests to Miniflare V3? HOT 1
- Support for typescript. HOT 1
- Is is it possible to collect coverage with vitest-environment-miniflare? HOT 2
- Increase better-sqlite3 compatibility HOT 1
- Uncaught error when initializing two top level WASM modules
- Multiple nodejs_compat packages missing (`crypto`, `path`, etc) HOT 4
- Fix CVE-2024-24758 HOT 3
- Type confusion HOT 1
- @miniflare/shared should not depend on @types/better-sqlite3 HOT 1
- Vitest bug: "Error: ENOENT: no such file or directory" HOT 2
- Workers: Error when an undefined value is exported in dev environment
- Type incompatibility issue between miniflare and workers-types HOT 4
- BUG: cannot install this library in node 22, please update better-sqlite3 HOT 1
- MiniflareCoreError [ERR_RUNTIME_FAILURE]: The Workers runtime failed to start. HOT 7
- How to test with `nodejs_compat` workers?
- How to use Worker's new native RPC feature? HOT 3
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from miniflare.