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

Error: Unexpected end of form at Multipart._final #369

Open
seveun opened this issue Dec 14, 2023 · 6 comments
Open

Error: Unexpected end of form at Multipart._final #369

seveun opened this issue Dec 14, 2023 · 6 comments

Comments

@seveun
Copy link

seveun commented Dec 14, 2023

using express with firebase on serverless function

app.ts =>

`import express from 'express';
import bluebird from 'bluebird';
import cors from 'cors';
import passport from 'passport';
import bodyParser from 'body-parser';
import fileUpload from 'express-fileupload';
import router from './routes';
import session from './config/Session';
import * as auth from './auth';

(global.Promise as unknown as typeof bluebird) = bluebird;

const app = express();
app.use(bodyParser.urlencoded({ extended: true }));
app.use(bodyParser.json());
app.use(fileUpload());
app.use(cors());
app.use(session);
app.use(router);
app.use(passport.initialize());
app.use(passport.session());
auth.init();

export default app;`

error => Error: Unexpected end of form at Multipart._final

my request is very simple :

export const patch = async (accessToken: string, body?: User, file?: any) => {
let formData
try {
if (file) {
formData = new FormData()
formData.append('file', file)
}
const { data } = await axios.patch(URL, formData || body, {
headers: {
Authorization: Bearer ${accessToken},
},
})
return data
} catch (err) {
return console.log(err)
}
}

@dedayoa
Copy link

dedayoa commented Dec 16, 2023

Just ran into this issue as well with gcp cloud functions. mscdex/busboy#296 (comment) mentions a solution which I can confirm works in my tests.

@hugoroussel
Copy link

@dedayoa having the same issue in local env with the gcp cloud function. Don't understand how the mscdex/busboy#296 (comment) helps since express-fileupload does not exposes to my knowledge the busboy object. Can you go into more details on how you solved your issue?

@dedayoa
Copy link

dedayoa commented Dec 18, 2023

@hugoroussel I was indicating that replacing req.pipe with busyboy.end(req.rawBody) in

req.pipe(busboy);
got things working...but by no means the solution.
I switched to cloud run instead.

@bitcoinbrisbane
Copy link

bitcoinbrisbane commented Jan 11, 2024

Same error. FYI I rolled back to 1.3.1 and it worked https://github.com/richardgirges/express-fileupload/releases

@bitcoinbrisbane
Copy link

@hugoroussel I was indicating that replacing req.pipe with busyboy.end(req.rawBody) in

req.pipe(busboy);

got things working...but by no means the solution.
I switched to cloud run instead.

Whats the work around? Im just using this on local machine.

@NorthernScythe
Copy link

NorthernScythe commented Mar 11, 2024

I recently got the same issue. It happened when I started using the Node.js cluster package to gain performance. It only happens when I try to upload binary files like PDF, MP4, etc... Reverting to a previous version of express-fileupload doesn't change anything for me... Anyone have any ideas?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants