-
Notifications
You must be signed in to change notification settings - Fork 5
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
Conversation
doHTTP is used be other services. changing this requires a bigger change
src/util/request-builder.js
Outdated
} | ||
} catch (error) { | ||
this._requestPromise.reject(new Error(Error.Severity.CRITICAL, Error.Category.NETWORK, Error.Code.BAD_SERVER_RESPONSE, error)); |
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.
define BAD_SERVER_RESPONSE
error object:
url,
headers,
responseText
src/util/request-builder.js
Outdated
}; | ||
request.onerror = error => { | ||
this._handleError(request, Error.Code.HTTP_ERROR, { | ||
error |
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.
remove the error, it is the DOM progress element.
add the status code and text
src/util/request-builder.js
Outdated
} | ||
|
||
_handleError(request: XMLHttpRequest, code: number, data: Object): Promise<*> | void { | ||
Object.assign(data, { |
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.
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({ |
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.
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 |
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.
call it errors
src/util/request-builder.js
Outdated
if (request.readyState === 4) { | ||
request.onreadystatechange = () => { | ||
if (request.readyState === 4) { | ||
try { |
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.
try catch only on JSON.parse
Description of the Changes
Adding a new configuration under providers for retrying multi requests:
Added the response headers to the reject data.
CheckLists