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

saveRequestFiles doesnt delete file when user cancels request #546

Open
2 tasks done
SupertigerDev opened this issue Sep 25, 2024 · 1 comment
Open
2 tasks done
Labels
bug Confirmed bug good first issue Good for newcomers

Comments

@SupertigerDev
Copy link

SupertigerDev commented Sep 25, 2024

Prerequisites

  • I have written a descriptive issue title
  • I have searched existing issues to ensure the bug has not already been reported

Fastify version

5.0.0

Plugin version

9.0.1

Node.js version

21

Operating system

Linux

Operating system version (i.e. 20.04, 11.3, 10)

Ubuntu 20.04

Description

  1. in postman, attach a large file
  2. Post the request and then cancel it
  3. See that the file is not deleted

Link to code that reproduces the bug

import Fastify from "fastify";
import multipart from "@fastify/multipart";
const fastify = Fastify({
  logger: true,
});
fastify.register(multipart, { logLevel: "error" });

fastify.post("/", async (request, reply) => {
  const files = await request.saveRequestFiles({
    limits: { files: 1, fields: 0, fileSize: 55655 * 1024 * 1024 },
  });

  reply.send({ test: "lol" });
});

fastify.listen({ port: 3000 });

edit: infact, it seems like saveRequestFiles promise just gets stuck forever or something

Expected Behavior

file should be deleted

Seems like the solution would be to add a catch block to pipeline and unlink the file

@mcollina
Copy link
Member

Thanks for reporting! Would you like to send a Pull Request to address this issue? Remember to add unit tests.

@mcollina mcollina added bug Confirmed bug good first issue Good for newcomers labels Sep 26, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Confirmed bug good first issue Good for newcomers
Projects
None yet
Development

No branches or pull requests

2 participants