Skip to content

timeout abnormal  #5238

Description

@XiaoTYUT

when i use node:18.13.0 and express:4.18.2 to upload file, Uploading will fail between 5 minutes and 6 minutes.
Firstly, response will emit "close". Secondly, request will be aborted.

Activity

  1. XiaoTYUT commented on Aug 6, 2023

    @XiaoTYUT
    Author

    here is my test code

    const app = express();

    app.post('/_/file/upload/put_file', (req: Request, res: Response) => {
    const fileStream = req.pipe(fs.createWriteStream('afse'));

    fileStream.on('finish', () => {
        res.send('success');
    });
    
    fileStream.on('error', (err: Error) => {
        res.status(500).send('failed');
    });
    
    req.on('error', (err: Error) => {
        console.log(`${new Date()}   req err  ${err}`);
    });
    
    req.on('close', () => {
        console.log(`${new Date()}   req close`);
    });
    
    res.on('error', (err: Error) => {
        console.log(`${new Date()}   res err  ${err}`);
    });
    
    res.on('close', () => {
        console.log(`${new Date()}   res close`);
    

    });
    });
    const port = 4000;

    app.listen(port, () => {
    console.log(${port});
    });

  2. changed the title [-]timeout abnormal[/-] [+]timeout abnormal [/+] on Aug 6, 2023
  3. XiaoTYUT commented on Aug 6, 2023

    @XiaoTYUT
    Author

    i try to set request timeout and response timeout , but it is not useful

  4. amitmumana commented on Nov 26, 2023

    @amitmumana
    app.post('/_/file/upload/put_file', (req, res) => {
        const fileStream = fs.createWriteStream('afse');
        
        req.pipe(fileStream);
    
        fileStream.on('finish', () => {
            res.send('success');
        });
    
        fileStream.on('error', (err) => {
            console.error(`${new Date()} File stream error: ${err}`);
            res.status(500).send('failed');
        });
    
        req.on('error', (err) => {
            console.error(`${new Date()} Request error: ${err}`);
        });
    
        req.on('close', () => {
            console.log(`${new Date()} Request closed`);
            fileStream.destroy();
        });
    
        res.on('error', (err) => {
            console.error(`${new Date()} Response error: ${err}`);
            fileStream.end();
        });
    
        res.on('close', () => {
            console.log(`${new Date()} Response closed`);
        });
    });
    

    Try this

    i think these changes will help and ensure that the file stream is properly closed and that errors are handled more gracefully, reducing the chances of upload failures.
    if will not work please specifie more info
    and info. about the content or format. which you trying to upload .

  5. locked and limited conversation to collaborators on Jul 12, 2025
  6. converted this issue into a discussion #6631 on Jul 12, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions