Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

GetObjectCommand circular reference #6009

Open
3 tasks done
vander99 opened this issue Apr 18, 2024 · 2 comments
Open
3 tasks done

GetObjectCommand circular reference #6009

vander99 opened this issue Apr 18, 2024 · 2 comments
Assignees
Labels
bug This issue is a bug. p3 This is a minor priority issue

Comments

@vander99
Copy link

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/core@8.4.7
aws-sdk/client-s3 version: 3.554.0

SDK version number

@aws-sdk/client-s3@3.556.0

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 vander99 added bug This issue is a bug. needs-triage This issue or PR still needs to be triaged. labels Apr 18, 2024
@aBurmeseDev aBurmeseDev self-assigned this Apr 23, 2024
@aBurmeseDev aBurmeseDev added investigating Issue is being investigated and/or work is in progress to resolve the issue. and removed needs-triage This issue or PR still needs to be triaged. labels Apr 23, 2024
@aBurmeseDev
Copy link
Member

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 aBurmeseDev added response-requested Waiting on additional info and feedback. Will move to \"closing-soon\" in 7 days. p3 This is a minor priority issue and removed investigating Issue is being investigated and/or work is in progress to resolve the issue. labels Apr 23, 2024
@vander99
Copy link
Author

Hello,

The error is related to the fact that the api returns a circular reference, so their is no way we could send the response anywhere by using http request.

The snippet is easy I shared it above, I want only to get the file from s3 and send it via http request so I can download it in my front end.

The question is, how can we get a file from s3 using nestjs and send it to a frontend by using http request knowing that the api returns a circular reference. If no is their a fix comming so the api won't return a circular reference. If no why does the api return a circular reference ?

@github-actions github-actions bot removed the response-requested Waiting on additional info and feedback. Will move to \"closing-soon\" in 7 days. label Apr 29, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug This issue is a bug. p3 This is a minor priority issue
Projects
None yet
Development

No branches or pull requests

2 participants