Skip to content

File stream upload to S3 leaks memory #3128

@glepur

Description

@glepur

Confirm by changing [ ] to [x] below to ensure that it's a bug:

Describe the bug
When you repeatedly upload file stream to S3 using upload method it infinitely increases memory usage of Node.js process.

Is the issue in the browser/Node.js?
Node.js

If on Node.js, are you running this on AWS Lambda?
No

Details of the browser/Node.js version
v12.13.0

SDK version number
v2.558.0

To Reproduce (observed behavior)
Run this code:

const AWS = require('aws-sdk')
const fs = require('fs')
const http = require('http')

const credentials = new AWS.Credentials({
  accessKeyId: '......',
  secretAccessKey: '........'
})
const S3 = new AWS.S3({
  credentials,
  region: 'eu-west-1'
})

http.createServer(async (req, res) => {
  const stream = fs.createReadStream('./test.mp4')
  await S3.upload({ Bucket: 'test', Key: 'test', Body: stream }).promise()

  res.end(JSON.stringify(process.memoryUsage(), null, 2))
}).listen(1234)

As you send requests to this server memory will infinitely increase.
I am using small video file, but you can use any file.

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions