- 
                Notifications
    You must be signed in to change notification settings 
- Fork 17
Add a timeout option for every request #632
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
Conversation
| Codecov Report
 @@            Coverage Diff             @@
##            7-dev     #632      +/-   ##
==========================================
- Coverage   86.18%   86.00%   -0.19%     
==========================================
  Files          34       35       +1     
  Lines        1593     1615      +22     
  Branches      280      294      +14     
==========================================
+ Hits         1373     1389      +16     
- Misses        162      166       +4     
- Partials       58       60       +2     
 Continue to review full report at Codecov. 
 | 
| | Property | Type<br/>(default) | Description | | ||
| | ---------- | ------------------------------- | --------------------------------------------------------------------------------------------------------------------- | | ||
| | `queuable` | <pre>boolean</pre><br/>(`true`) | If true, queues the request during downtime, until connected to Kuzzle again | | ||
| | `timeout` | <pre>number</pre> | Time (in ms) during which a request will still be waited to be resolved. Set it `-1` if you want to wait indefinitely | | 
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
So at this action, the timeout has no default?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There is a default timeout but IDK how to explain that the default timeout  is  the global timeout configured in the Kuzzle constructor if it has been configured or -1 otherwise, meaning that there is no timeout
| refresh?: 'wait_for', | ||
| timeout?: number | 
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In the future we should take a look at how to handle these 'shared' options for all queries, having 'refresh' and now 'timeout' could just be the beginning of having tons of query oriented options for every API action.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You're right, it might be a good thing to have a better way of handling this kind of shared params, this might need a Workshop
What does this PR do ?
This PR adds a default timeout to every request and a new option timeout to the method
queryand the actions of the following controllers:login&logout)This new option can be used to set a timeout (in ms) to every request sent, after the timeout if the request has not been resolved yet the promise will be rejected with a message saying that the request has timed out.
It's also possible to configure a global requestTimeout in the kuzzle constructor.
If the timeout is set to
-1the promise will never be reject and will be waited indefinitely.Boyscout
Reformatting of tables in markdown files