fastify / fastify/help

Help! Memory not freeing when receiving multipart files when ERR_STREAM_PREMATURE_CLOSE

Open
#876 4 comments 0 reactions 0 assignees View on GitHub
help wanted
Dominant language
No language data
Stars
68
Forks
8
Avg merge
11h 2m
Merged PRs (30d)
2

Description

## 💬 Memory not freeing when receiving multipart files when ERR_STREAM_PREMATURE_CLOSE
How can I make Fastify clear up memory when an error occurs during request.saveRequestFiles() specifically ERR_STREAM_PREMATURE_CLOSE?

I have tried below code but it still doesn't free up memory
```js
let files;

try {
files = await request.saveRequestFiles();
} catch (e) {
console.log("Error saving files", e);
await request.cleanRequestFiles();
reply.code(500).send("Internal Server Error");
return;
}
```
[GitHub](https://github.com/Kuyumee/kuyumee-api/blob/main/api/upload.js#L2-L12)

The graph shows that it takes half a day for the uploaded data to be released from memory
![image](https://user-images.githubusercontent.com/69566792/236740272-d2d7dd7c-b102-47e8-a72d-54cc22c75882.png)

## Your Environment
- *node version*: v16.17.0
- *fastify version*: ^4.17.0
- *os*: Windows

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.