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

Converting circular structure to JSON #643

Closed
ownagedj opened this issue Dec 1, 2020 · 7 comments · Fixed by #679
Closed

Converting circular structure to JSON #643

ownagedj opened this issue Dec 1, 2020 · 7 comments · Fixed by #679
Assignees
Labels

Comments

@ownagedj
Copy link

ownagedj commented Dec 1, 2020

When calling the SponsoredProductsReportOperation.getReport() method, the client can run into an exception where it tries to JSON.stringify() the full response object, resulting in Converting circular structure to JSON

See: https://github.com/ScaleLeap/amazon-advertising-api-sdk/blob/master/src/http-client.ts#L87

Node: v14.14.0
Package Version: 1.30.9

"message": "Converting circular structure to JSON\n    --> starting at object with constructor 'ClientRequest'\n    |     property 'socket' -> object with constructor 'TLSSocket'\n    --- property '_httpMessage' closes the circle",
"stack": [
  {
    "filename": null,
    "function": null,
    "line": null
  },
  {
    "filename": null,
    "function": "stringify",
    "line": null
  },
  {
    "filename": "@scaleleap/amazon-advertising-api-sdk/lib/http-client.js",
    "function": "handleApiResponse",
    "line": 62
  },
  {
    "filename": "@scaleleap/amazon-advertising-api-sdk/lib/http-client.js",
    "function": "apiRequest",
    "line": 85
  }

The response of the api is the following

...
      host: [ 'Host', 'advertising-api-eu.amazon.com' ]
    }
  },
  data: 'Number of requests exceeded maximum allowed request rate.'
}
@moltar
Copy link
Contributor

moltar commented Dec 2, 2020

Do you have an example of a request that causes this issue? Thanks!

@ownagedj
Copy link
Author

ownagedj commented Dec 3, 2020

Unfortunately not.
Just call the method until you run into the rate limit of Amazon.

@moltar
Copy link
Contributor

moltar commented Dec 3, 2020

Ok, so this happens on any request, but only when it gets throttled?

@moltar
Copy link
Contributor

moltar commented Jan 4, 2021

@nguyentoanit please look at this. I am also experiencing this issue.

@nguyentoanit nguyentoanit linked a pull request Jan 5, 2021 that will close this issue
@moltar
Copy link
Contributor

moltar commented Jan 7, 2021

@ownagedj do you know which endpoint causes this?

Seems like data is not a well defined object, as documented, but instead it is a simple string:

Number of requests exceeded maximum allowed request rate.

Can you confirm that?

Thanks.

moltar added a commit that referenced this issue Jan 7, 2021
github-actions bot pushed a commit that referenced this issue Jan 12, 2021
## [1.30.15](v1.30.14...v1.30.15) (2021-01-12)

### Bug Fixes

* converting circular structure to json ([2d08e31](2d08e31))
* converting circular structure to JSON error ([6b9bab6](6b9bab6)), closes [#643](#643)
@github-actions
Copy link

🎉 This issue has been resolved in version 1.30.15 🎉

The release is available on:

Your semantic-release bot 📦🚀

@moltar
Copy link
Contributor

moltar commented Jan 15, 2021

@ownagedj did you have time to test the new version?

@moltar moltar closed this as completed Jul 30, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants