Hey all! I’m having a bit of a weird issue and wondering if somebody has experience with this.
I have a SMI function that downloads something with axios as an arraybuffer and then uploads it to an AWS S3 bucket. This works great when I test it using fdk run. When I fdk pack the app and test the app there, I get the following error (I can see it when I go to the custom app > View Log) :
An error occurred while uploading the file: Error [ERR_HTTP_HEADERS_SENT]: Cannot set headers after they are sent to the client at new NodeError (node:internal/errors:399:5) at ClientRequest.setHeader (node:_http_outgoing:645:11) at protocols.<computed>.request (/opt/framework/index.js:53:13) at /var/task/developer/node_modules/@aws-sdk/node-http-handler/dist-cjs/node-http-handler.js:72:25 at new Promise (<anonymous>) at NodeHttpHandler.handle (/var/task/developer/node_modules/@aws-sdk/node-http-handler/dist-cjs/node-http-handler.js:51:16) at process.processTicksAndRejections (node:internal/process/task_queues:95:5) at async /var/task/developer/node_modules/@aws-sdk/middleware-serde/dist-cjs/deserializerMiddleware.js:5:26 { code: 'ERR_HTTP_HEADERS_SENT', '$metadata': { attempts: 1, totalRetryDelay: 0 } }
The piece of code that throws the error is the uploading with the s3Client, and it looks like this:
console.log("Sending upload command...");
const uploadCommand = new PutObjectCommand({
Bucket: options.iparams.recordingBucketName,
Key: key,
Body: recordingFile,
});
s3Client
.send(uploadCommand)
.then((response) => {
console.log("File uploaded successfully!", response);
})
.catch((error) => {
console.error("An error occurred while uploading the file:", error);
});
console.log("File uploaded successfully.");
Does anybody have any idea why this would happen?
Edit 1: I also just double checked if all my iparams and variables are correct. I thought maybe there was a problem there, but they all are correct in the SMI function.