Open
Bug 1473777
Opened 6 years ago
Updated 2 years ago
use getData function in lieu of fetch directly (where possible)
Categories
(Tree Management :: Treeherder: Frontend, defect, P3)
Tree Management
Treeherder: Frontend
Tracking
(Not tracked)
NEW
People
(Reporter: camd, Unassigned)
References
(Blocks 1 open bug)
Details
Attachments
(2 files)
Fix error handling in places where were our calls have switched to using fetch. When using $http, you would check for errors by having something like this: $http.get(url).then((success) => { ... }, (error) => { ... }); But with fetch, you don't use the second callback, you check the response for ``.ok`` like: fetch.get(url).then((resp) => { if (resp.ok) { // success } else { // fail, throw an exception... } }).catch(error => alert somehow...) The catch gets hit directly only when you have connectivity issues and a few other circumstances. 400 and 500 response codes still go to the first call in the .then.
Reporter | ||
Updated•6 years ago
|
Assignee: nobody → cdawson
Status: NEW → ASSIGNED
Priority: -- → P2
Reporter | ||
Comment 1•6 years ago
|
||
https://www.tjvantoll.com/2015/09/13/fetch-and-errors/
Comment 2•6 years ago
|
||
Reporter | ||
Updated•6 years ago
|
Attachment #8990419 -
Flags: review?(emorley)
Updated•6 years ago
|
Attachment #8990419 -
Flags: review?(emorley) → review+
Comment 3•6 years ago
|
||
Commit pushed to master at https://github.com/mozilla/treeherder https://github.com/mozilla/treeherder/commit/d60baca64fc737ab313eb2648bee551be24cd67a Bug 1473777 - Fix Treestatus for unsupported repos (#3768)
Reporter | ||
Updated•6 years ago
|
Blocks: treeherder-react
Comment 5•6 years ago
|
||
Comment 6•6 years ago
|
||
Commit pushed to master at https://github.com/mozilla/treeherder https://github.com/mozilla/treeherder/commit/60052faa19f25653e03fd89233a8c03060e862b0 Bug 1473777 - Fix error message if job is missing
Comment 7•6 years ago
|
||
As part of working on this, it would be good to special-case HTTP 503s and ensure that the error message shown to the user says "Request exceeded maximum API time limit" or something along those lines - since the default Heroku page content says "app unavailable" which is misleading. Perhaps an helper wrapper for all fetch calls would be useful?
Blocks: 1504990
Summary: When using fetch, must check response.ok for errors → When using fetch, must check response.ok for errors (and special-case HTTP 503)
Comment 8•6 years ago
|
||
As part of the perfherder conversion I moved the `getData` method (designed to return error messages in json responses or plain text) from IFV's helpers into the general `helpers/http.js` file. export const getData = async function getData(url) { let failureStatus = null; const response = await fetch(url); if (!response.ok) { failureStatus = response.status; } if (response.headers.get('content-type') === 'text/html' && failureStatus) { return { data: { [failureStatus]: response.statusText }, failureStatus }; } const data = await response.json(); return { data, failureStatus }; }; But, for the case of the 503's I noticed IFV doesn't show the special message I programmed for this type of error (in a separate helper function) because it seems Heroku by default returns the "app unavailable" page unless we set a customized page to be returned instead: https://devcenter.heroku.com/articles/error-pages.
Reporter | ||
Updated•5 years ago
|
Summary: When using fetch, must check response.ok for errors (and special-case HTTP 503) → use getData function in lieu of fetch directly (where possible)
Updated•5 years ago
|
No longer blocks: treeherder-react
Comment 9•5 years ago
|
||
Comment 10•5 years ago
|
||
PushModel.getList is being updated via bug 1527824.
Updated•5 years ago
|
Reporter | ||
Updated•5 years ago
|
Assignee: cdawson → nobody
Status: ASSIGNED → NEW
Priority: P2 → P3
You need to log in
before you can comment on or make changes to this bug.
Description
•