I am adding logging to our UI to track various aspects of our page load duration, including the amount of time BE API calls take to return from the server. I know that in the past, switching tabs caused issues with things like setTimeout/Interval and requestAnimationFrame, but wasn't sure if this applied to other, newer async features like generator functions, fetch or the performance api.
Can anyone confirm if the following would be OK, or if the logged duration of the API call would be incorrect if the user switched to another tab for a few minutes before switching back while the API call was in progress?
(we are using React, Redux, Redux Sagas, Babel, Webpack and whatwg-fetch)
const { name, get } = api.foo;
const { mark, getEntriesByName } = window.performance;
mark(name);
response = yield call(get, payload); // user switches to another tab while processing
// user switches back after 2 minutes
const duration = getEntriesByName(name).pop().duration;
yield put(actions.logQueryDuration(name, duration))
in the above example, if the API call actually only takes 10 seconds to return, will the logged duration show 10 seconds or 2 minutes?
Thanks!