Skip to content
This repository was archived by the owner on Jan 31, 2025. It is now read-only.

Commit 2c512ae

Browse files
author
Daniel Brain
committed
Add default timeout to onWindowReady
1 parent 734144a commit 2c512ae

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

src/lib/ready.js

+5-2
Original file line numberDiff line numberDiff line change
@@ -29,15 +29,18 @@ export function initOnReady() {
2929
}
3030
}
3131

32-
export function onWindowReady(win) {
33-
return new promise.Promise(resolve => {
32+
export function onWindowReady(win, timeout = 5000) {
33+
return new promise.Promise((resolve, reject) => {
34+
3435
if (readyWindows.indexOf(win) !== -1) {
3536
return resolve(win);
3637
} else {
3738
readyPromises.push({
3839
win,
3940
resolve
4041
});
42+
43+
setTimeout(() => reject(new Error(`Bridge did not load after ${timeout}ms`)), timeout);
4144
}
4245
});
4346
}

0 commit comments

Comments
 (0)