0

I am trying to create an S3Client using the @aws-sdk/client-s3 package, as shown below:

const { S3Client } = require('@aws-sdk/client-s3')
const client = new S3Client({ region: 'us-east-1' })

It runs fine locally, but when I upload the code to a MongoDB Realm function along with the client-s3 dependency, it throws the error: {"message":"'emitWarning' is not a function","name":"TypeError"}

What might be causing this error?

wristbands
  • 1,021
  • 11
  • 22

1 Answers1

0

It turns out this was happening because the MongoDB Realm Functions environment does not have an emitWarning function defined on the global process variable, which is why the error kept saying 'emitWarning' is not a function.

I reached out to MongoDB Support about this, and apparently the AWS-SDK v3 just isn't compatible with MongoDB Realm Functions.

Instead, you must use the AWS-SDK v2. I eventually found this MongoDB Forums Article, which explained that they specifically support v2.737.0 of the SDK.

wristbands
  • 1,021
  • 11
  • 22