-
Notifications
You must be signed in to change notification settings - Fork 26
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
Too Many Requests Error from Google (a production environment issue) solved with rates caching for currency pairs #34
Conversation
I just realized some issues with my rate caching solution.
|
Hi Paul, I just want to let you know that if you want, I can make all the changes including the changes to the README file in another pull request. Kindly let me know if you want to update the tool to include caching. |
Hi @olarotseyi, thanks for your contribution. I think that's a great idea to address the "429 Too many requests". I've some suggestions:
Let me know what you think. I've also checked your contribution to my other project. Once, I merge your request, you'll automatically become a contributor. 😃 |
Hi @paul-shuvo, thank you for considering my pull request.
|
Hey @paul-shuvo, I have made some updates to my solution and I have updated the README and the test.js files to reflect the updates. I have also made the updates to the nodejs-crypto-converter |
Hey @paul-shuvo, I just wanted to follow up on this pull request and the similar pull request I made to the crypto converter package. Is there any thing you think I should include in the rates caching solution? |
Hi @olarotseyi , I went through your pull request. Here are some issues:
Let me know if you have any question. |
Hey @paul-shuvo, thank you for pointing out the tests that were failing. I was able to fix the issues and pass all the tests in both the node-currency-converter tool and the nodejs-crypto-converter tool. |
Hey @paul-shuvo, I noticed an issue with my rate caching. I just noticed that the setTimeout function does not have access to the global objects such as this.currencyFrom and this.ratesCache and therefore the rate would not be deleted from the cache as expected, instead the application crashes. I am currently working to fix this by making each rate an object that has one value representing it's expiry date. |
I fixed the issue with overwriting instead of deletion. Each rate is now stored as an object with two properties, the actual rate and an expiry date. The expiry date is calculated using the ratesCacheDuration that is set by the user. The rate for a currency pair will not be deleted from the rates cache after the expiry date instead, it will be overwritten with the new rate and new expiry date when a request is made for the currency pair after the old rate of the currency pair has expired. I fixed the issue in the nodejs-crypto-converter tool also. |
Any plans for this to get merged soon? It would really help out. Thanks @paul-shuvo |
Hi @toluolatubosun, were you able to find a working currency converter to use? |
…lity issue with the got package
Hi @paul-shuvo, I noticed an issue with the got package when I ran a test of my implementation of the currency converter tool. The got package was randomly giving a particular error that has not been fixed in the got package and it seems it will take some time to fix the error. I decided to replace the got package with the request package and I made the same change to the crypto converter tool. |
Hi @olarotseyi, many thanks for your contribution and apologies for this late feedback/comment. I checked your pull request some time ago and it had some issues (at least at my end). I myself was thinking of replacing |
Hi @paul-shuvo, I made the changes in a way I thought would ensure seamless integration. I will appreciate it if you can run the tests again and provide some feedback on any issues if you find any issues. Also, if you run the tests again and there are no issues, you can approve the merge as a new major version. I think developers using the tool have to manually change the version of the tool in their .env files to enable the latest version and I would suggest that developers run some tests before updating to the newer version of this tool. I believe the update will integrate with smoothly with existing projects using the tool. |
Hi @olarotseyi , I'm getting the following test fails. |
Hi @paul-shuvo, I have made a new commit to fix the issues and all the tests were passed on my end. |
Hi @paul-shuvo, thanks for pointing that out. The tests needed for the setupRatesCache function are already added. I just added tests for the addRateToRatesCache function. The tests work in a way where by all the existing tests must be passed for the tool to be useful. So even if it looks like some of the lines are not covered, they are actually covered by tests in other functions. For example, while adding tests to the addRateToRatesCache function, I noticed that the additional errors that I was trying to catch would actually be caught by the tests for the rates function or the convert function. |
Hi @paul-shuvo, thanks for the merge! |
Hey @toluolatubosun I don't know if you got the email about the merge but this updated tool is now ready for everybody to use! |
Hi Paul, first I want to thank you for this contribution to the Nodejs community. I have been building with the script from this package that you sent to me via email a while ago. I recently noticed that there could be a serious issue when using this package in a production environment. Google has a rate limit feature and too many requests within a short period of time will lead to a "429 Too many requests" error. Luckily, I have figured out a solution to this issue and I hope you accept my pull request.