Comments (12)
I've done some sleuthing and I think I know what is going on. I believe:
- For rate limiting, Desk is returning a 429 with mime type JSON but a non-JSON body:
"Too Many Requests"
- Faraday is attempting to parse the non-JSON body as JSON and throwing an error
- Faraday is not even reaching the desk gem's custom 4xx handler
from desk.
@alexanderdean you are totally right and that was a known issue (that I totally forgot to go back and fix). That bug actually effects any time the Desk API has issues (so 500 errors, etc). If you're already working on fixing it then that's awesome, however, if you want some help, I have some time today that I can work on getting it fixed.
from desk.
Hi @colinc - a bit of help would be amazing - my Faraday-fu is not at all strong! Very happy to test anything you write...
from desk.
@alexanderdean No problem. I've got a handful of commitments this morning and then I'll jump right on this.
from desk.
Amazing thanks!
from desk.
This was basically a one line fix! I ripped out some of the old XML code since they're only using JSON responses now. I guess I need to go through and find any other unnecessary XML code and clean that up as well.
I'm glad I got into that code though because I think there's some improvements that can be made to optionally allow the Desk gem to handle the rate limiting itself.
In the meantime, @alexanderdean can you see if this all works for you?
Here's the test I was using to verify the changes @alexanderdean and I made.
(0..125).each do |i|
begin
Desk.cases
rescue Desk::EnhanceYourCalm => e
sleep(e.retry_after)
end
end
from desk.
Confirmed - that's working great for me, huge thanks @colinc . Here is my test:
1.9.3-p484 :012 > require "parallel"
=> true
1.9.3-p484 :013 > results = Parallel.map((1000..100000), :in_threads=>30) do |idx|
1.9.3-p484 :014 > begin
1.9.3-p484 :015 > Desk.case(idx)
1.9.3-p484 :016?> rescue Desk::EnhanceYourCalm => e
1.9.3-p484 :017?> puts "Enhance your calm for #{e.retry_after}s"
1.9.3-p484 :018?> sleep(e.retry_after)
1.9.3-p484 :019?> end
1.9.3-p484 :020?> end
Enhance your calm for 22s
Enhance your calm for 22s
Enhance your calm for 22s
Enhance your calm for 22s
Enhance your calm for 22s
Enhance your calm for 22sEnhance your calm for 22s
Enhance your calm for 22s
Enhance your calm for 22s
Enhance your calm for 21s
Enhance your calm for 21s
Enhance your calm for 21s
Enhance your calm for 21s
Enhance your calm for 21s
Enhance your calm for 21s
Enhance your calm for 21s
Enhance your calm for 21s
Enhance your calm for 21s
Enhance your calm for 21s
Enhance your calm for 21s
Enhance your calm for 21s
Enhance your calm for 21s
Enhance your calm for 21s
Enhance your calm for 21s
Enhance your calm for 21s
Enhance your calm for 21s
Enhance your calm for 21s
Enhance your calm for 21s
Enhance your calm for 21s
Enhance your calm for 21s
How do we get all these changes merged and a new release cut?
from desk.
+1 for the new release. Running into same issue. Thanks for all the hard work guys!
from desk.
@colinc - you okay to raise a PR into this project with your fix?
from desk.
@colinc any chance you can raise a PR?
from desk.
Hey @chriswarren - there are some further changes in @colinc's branch - unfortunately I don't think he ever raised a PR but his fixes are needed too...
from desk.
I think this is all merged in now, so I'm closing the ticket. If it's not let us know.
from desk.
Related Issues (20)
- Copy-paste errors in ratelimit_remaining
- Please update faraday dependency / conflicts with google oauth2 HOT 1
- gem "hashie" issue HOT 7
- Search case by order_no HOT 7
- collections only respond to each instead of all of Enumerable HOT 4
- Raise Desk-namespaced exceptions for other non-200 responses
- 422 error response not parsed correctly HOT 5
- Faraday::ParsingError: 757: unexpected token at 'Too Many Requests' HOT 1
- Desk.com gem ignores client config? HOT 2
- Desk.delete_case is not working HOT 3
- Logger does not log request and response body
- Document how to log request and response
- RuntimeError: missing dependency for FaradayMiddleware::Deashify: undefined method `type' for class `Hashie::Mash' HOT 9
- Incorrect from/reply_to address
- Configuration Issue
- Desk.insights_meta produces a 404 HOT 2
- Problem with the Thread.current in the Configuration HOT 1
- Bug when creating articles HOT 1
- Hashie fixed version giving conflicts HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from desk.