Skip to content

Canceled uploads are not propagated to the part.file FileReadStream #315

@mccare

Description

@mccare

Prerequisites

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

Fastify version

3.25.3

Plugin version

5.2.1

Node.js version

16.13.1

Operating system

macOS

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

12.1

Description

When a user cancels the upload request, the cancel/destroy event is not propagated to the part.file FileReadStream. The request is not ended. Cleanup code that lives e.g. in the finally of my try/catch block is not called (e.g. to remove tempfiles).

Steps to Reproduce

I've created a sample repo here https://github.com/mccare/multipart-upload-error-handling

  • yarn install and run yarn dev
  • curl -i --limit-rate 100k -w '%{http_code}\n' -F [email protected] -F [email protected] http://localhost:3000/upload
  • Terminate curl before request has gone through

The log files will show that the finally block is never reached. I'm assuming the request is not finished

Expected Behavior

The code should throw some sort of error and the execution should at least reach the finally clause of my request handler.

I have added a close handler for request.raw to cancel/destroy the part.file Readable. This produces the expected results, but I don't know if that is the correct way to handle this.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions