Skip to content

Commit cca8d4b

Browse files
authored
[Auth] Fix promise rejection for failing when loading JS (#5145)
* Fix promise rejection for loading JS * PR feedback * Formatting * PR feedback
1 parent e0f84b5 commit cca8d4b

File tree

1 file changed

+8
-1
lines changed
  • packages-exp/auth-exp/src/platform_browser

1 file changed

+8
-1
lines changed

packages-exp/auth-exp/src/platform_browser/load_js.ts

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,9 @@
1515
* limitations under the License.
1616
*/
1717

18+
import { AuthErrorCode } from '../core/errors';
19+
import { _createError } from '../core/util/assert';
20+
1821
function getScriptParentElement(): HTMLDocument | HTMLHeadElement {
1922
return document.getElementsByTagName('head')?.[0] ?? document;
2023
}
@@ -25,7 +28,11 @@ export function _loadJS(url: string): Promise<Event> {
2528
const el = document.createElement('script');
2629
el.setAttribute('src', url);
2730
el.onload = resolve;
28-
el.onerror = reject;
31+
el.onerror = e => {
32+
const error = _createError(AuthErrorCode.INTERNAL_ERROR);
33+
error.customData = e as unknown as Record<string, unknown>;
34+
reject(error);
35+
};
2936
el.type = 'text/javascript';
3037
el.charset = 'UTF-8';
3138
getScriptParentElement().appendChild(el);

0 commit comments

Comments
 (0)