Skip to content

Inconsistent Behaviour and Errors with Digital Ocean Spaces. #3885

@nevil2

Description

@nevil2

Checkboxes for prior research

Describe the bug

My application randomly stops working correctly (after a few hours, days or more) with the following errors:

ListBucketsCommand returns no buckets or owner (just $metadata)
getSignedUrl returns invalid url with bucket infront of key: https://{bucket}ams3.digitaloceanspaces.com/)/{bucket}/{filename}?..........
Upload puts file in a directory {bucket}/{filename}

Once an error occurs, they remain, but disappear as soon as I restart the container (and recreate the S3client). This suggests that the error is with the S3client. I have contacted Digital Ocean who are unable to identify the problem.

The essence of my JavaScript code is shown below. MyAccessKey / MySecretKey are constants, Bucket / Key are variables and MyStream is a stream created from the file to be uploaded. The console log proves that I am giving the commands the correct bucket and key.

import { S3Client, GetObjectCommand, ListBucketsCommand } from '@aws-sdk/client-s3'
import { getSignedUrl } from '@aws-sdk/s3-request-presigner'
import { Upload } from '@aws-sdk/lib-storage'

const client = new S3Client({
endpoint: 'https://ams3.digitaloceanspaces.com/',
region: 'ams3',
credentials: { accessKeyId: MyAccessKey, secretAccessKey: MySecretKey }
})

const reply = await client.send(new ListBucketsCommand({}))

const command = new GetObjectCommand({ Bucket, Key })
console.log(`Download request: Bucket: ${Bucket}, Key: ${Key}`)
const url = await getSignedUrl(client, command, { expiresIn: 120 })

const params = { Bucket, Key, Body: MyStream, ContentType }
const uploader = new Upload({ client, params })
await uploader.done()

SDK version number

@AWS-SDK v3.154

Which JavaScript Runtime is this issue in?

Node.js

Details of the browser/Node.js/ReactNative version

v18.1.0

Reproduction Steps

The error start randomly (after a few hours, days or more)

Observed Behavior

ListBucketsCommand returns:

{
  "$metadata":{"httpStatusCode":200,"attempts":1,"totalRetryDelay":0}
}

Expected Behavior

ListBucketsCommand returns:

{
  "$metadata":{"httpStatusCode":200,"attempts":1,"totalRetryDelay":0},
  "Buckets":[ 
    {"Name":"xxxxxxxxx","CreationDate":"2022-07-21T13:10:17.975Z"},
    {"Name":"xxxxxxxxx","CreationDate":"2022-06-20T14:59:17.306Z"},
],
  "Owner":{"DisplayName":"xxxxxxxx","ID":"xxxxxxxxx"}
}

Possible Solution

A possible solution for me might be to create new client with every request.

Additional Information/Context

I have the same application running as docker containers on two separate Digital Ocean droplets (for different clients), each working with separate Digital Ocean Spaces accounts.

The errors have been occurring for some time (i.e. with previous @AWS-SDK versions) perhaps since I upgraded to Version 3 a couple of months ago.

Metadata

Metadata

Assignees

Labels

bugThis issue is a bug.

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions