Skip to content

Commit

Permalink
[INTERNAL][FIX] ui5loader: avoid 'Uncaught (in promise)' log entries
Browse files Browse the repository at this point in the history
To support a mixture of sync and async module loading, the ui5loader
creates a Promise for any requested resource to track its loading state,
even when the first requestor uses a synchronous API.

As long as no asynchronous API asks for the same resource, this promise
is never used. Modern browsers report a rejection of such a promise as
'Uncaught (in promise)' error and report it on the console.

One solution would be to create the Promise only on demand, but then
error tracking would be more complicated. As an alternative, this change
adds a dummy catch handler to the promise. This has no impact on error
reporting via APIs (errback - covered by tests).

For some background, see the discussion about rejected promises ( 
nodejs/node#830 ) and the current answer of
the HTML5 spec to the topic (
https://html.spec.whatwg.org/multipage/webappapis.html#unhandled-promise-rejections
)

Change-Id: I99e5c1384a4e5caf7ccdf21db1dfadbdc75884f3
CR-Id: 002075125900000687202018
(cherry picked from commit 47ac957)
BCP: 1880209531
  • Loading branch information
codeworrior committed Mar 23, 2018
1 parent 7c5b8c9 commit 3215dfa
Showing 1 changed file with 2 additions and 0 deletions.
2 changes: 2 additions & 0 deletions src/sap.ui.core/src/ui5loader.js
Expand Up @@ -725,6 +725,8 @@
deferred.resolve = resolve;
deferred.reject = reject;
});
// avoid 'Uncaught (in promise)' log entries
deferred.promise.catch(noop);
}
return this._deferred;
};
Expand Down

0 comments on commit 3215dfa

Please sign in to comment.