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
  • Loading branch information
codeworrior committed Feb 7, 2018
1 parent b16f185 commit 47ac957
Showing 1 changed file with 2 additions and 0 deletions.
2 changes: 2 additions & 0 deletions src/sap.ui.core/src/ui5loader.js
Original file line number Diff line number Diff line change
Expand Up @@ -699,6 +699,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 47ac957

Please sign in to comment.