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

feat(FEC-8601): Add network requests retry mechanism and headers data to the error #66

Merged
merged 18 commits into from
Nov 18, 2018

Conversation

odedhutzler
Copy link
Contributor

@odedhutzler odedhutzler commented Nov 11, 2018

Description of the Changes

Adding a new configuration under providers for retrying multi requests:

networkretryParameters:{
  timeout?: number,
  maxAttempts?: number
}

Added the response headers to the reject data.

CheckLists

  • changes have been done against master branch, and PR does not conflict
  • new unit / functional tests have been added (whenever applicable)
  • test are passing in local environment
  • Travis tests are passing (or test results are not worse than on master branch :))
  • Docs have been updated

doHTTP is used be other services.

changing this requires a bigger change
}
} catch (error) {
this._requestPromise.reject(new Error(Error.Severity.CRITICAL, Error.Category.NETWORK, Error.Code.BAD_SERVER_RESPONSE, error));
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

define BAD_SERVER_RESPONSE error object:

url,
headers,
responseText

};
request.onerror = error => {
this._handleError(request, Error.Code.HTTP_ERROR, {
error
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

remove the error, it is the DOM progress element.
add the status code and text

}

_handleError(request: XMLHttpRequest, code: number, data: Object): Promise<*> | void {
Object.assign(data, {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

extract this to _createErrorObject method

1. add MULTIREQUEST_API_ERROR
2. add API_RESPONSE_MISMATCH
3. structurize the error rejects.
@@ -41,11 +41,26 @@ export default class MultiRequestBuilder extends RequestBuilder {
return new Promise((resolve, reject) => {
this.doHttpRequest().then(
data => {
resolve(new MultiRequestResult(data));
const multiRequestResult = new MultiRequestResult({
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

no need for object if we reduced to single param

new Error(Error.Severity.CRITICAL, Error.Category.NETWORK, Error.Code.MULTIREQUEST_API_ERROR, {
url: this.url,
headers: this.responseHeaders,
serviceErrors: multiRequestResult.error
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

call it errors

if (request.readyState === 4) {
request.onreadystatechange = () => {
if (request.readyState === 4) {
try {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

try catch only on JSON.parse

OrenMe
OrenMe previously approved these changes Nov 18, 2018
@OrenMe OrenMe merged commit 695f68a into master Nov 18, 2018
@OrenMe OrenMe deleted the FEC-8601 branch November 18, 2018 09:01
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Development

Successfully merging this pull request may close these issues.

2 participants