richardgirges / express-fileupload

Simple express file upload middleware that wraps around busboy
MIT License
1.52k stars 261 forks source link

option.limitHandler and request handler all called. #285

Closed ChenYangY closed 9 months ago

ChenYangY commented 3 years ago
const express = require('express');
const fileUpload = require('express-fileupload');

const app = express();

app.use(fileUpload({
    limits: {fileSize: 100 * 1024},
    abortOnLimit: true,
    limitHandler: (req, res) => {
        res.json({error: 'error'});
    }
}))

app.post('/upload', (req, res) => {
    res.end('next');
})

app.listen(8686);

this is my test code.

it happened some error when i uploaded an file(greater than 100kb).

Error [ERR_STREAM_WRITE_AFTER_END]: write after end

so i want the process abort at limithandler, what should i do?

node: 14.16.0 express: 4.17.1 express-fileupload: 1.2.1 platform: mac

RomanBurunkov commented 9 months ago

Hi,

This issue has been solved in version 1.4.2.