aws-sdk-js-v3 icon indicating copy to clipboard operation
aws-sdk-js-v3 copied to clipboard

GetObjectCommand circular reference

Open vander99 opened this issue 1 year ago • 2 comments

Checkboxes for prior research

Describe the bug

Hello, I am trying to download a file from nestjs, send it to angular server using a REST POST endpoint in order to trigger the download of this file.

But I get this error: ERROR [ExceptionsHandler] Converting circular structure to JSON --> starting at object with constructor 'TLSSocket' | property 'parser' -> object with constructor 'HTTPParser' --- property 'socket' closes the circle Do you have a solution to this probleme ?

Her is my controller: @Post('download') async downloadFile(@Body() body:bodyObject) { return await this.s3Client.send( new GetObjectCommand({ Bucket: 'bucket-name', Key: file-name, })); }

My nodejs version: v20.10.0 nestjs version: @nestjs/[email protected] aws-sdk/client-s3 version: 3.554.0

SDK version number

@aws-sdk/[email protected]

Which JavaScript Runtime is this issue in?

Node.js

Details of the browser/Node.js/ReactNative version

v20.10.0

Reproduction Steps

Download a file from s3 using GetObjectCommand then send it by rest endpoint to a frontend server

@Post('download') async downloadFile(@Body() body:bodyObject) { return await this.s3Client.send( new GetObjectCommand({ Bucket: 'bucket-name', Key: file-name, })); }

Observed Behavior

Error:

ERROR [ExceptionsHandler] Converting circular structure to JSON --> starting at object with constructor 'TLSSocket' | property 'parser' -> object with constructor 'HTTPParser' --- property 'socket' closes the circle

Expected Behavior

The file to be send, so we can trigger then download in the frontend

Possible Solution

No response

Additional Information/Context

No response

vander99 avatar Apr 18 '24 17:04 vander99

Hi @vander99 - thanks for reaching out.

i think the error you're seeing is more of NestJS related rather than SDK. From my quick research, this error is occurs when you try to convert an object into JSON but the object contains a circular reference. Here are my search results.

If you need further assistance, please share a larger code snippet of your file to give me more insight.

Hope it helps, John

aBurmeseDev avatar Apr 23 '24 19:04 aBurmeseDev

Hi, Any solution on this. I have been fighting this issue for a full day now.

whutchtwo avatar May 19 '24 20:05 whutchtwo