When a callback JS function add new async callback, the JS execution stops w/o waiting for the last async callbacks.
window.addEventListener("load", () => {
const detailsXHR = new XMLHttpRequest();
detailsXHR.open('GET', 'http://httpbin.io/json');
detailsXHR.onloadend = function() {
// the function callback is never called
};
detailsXHR.send();
});