Skip to content

Commit 196a96d

Browse files
mababainMaksim
andauthored
fix(docs): add reject in promise-based dynamic remote (#2264)
Co-authored-by: Maksim <[email protected]>
1 parent 8632f69 commit 196a96d

File tree

1 file changed

+7
-2
lines changed

1 file changed

+7
-2
lines changed

apps/docs/src/en/modules/ROOT/pages/core-features/dynamic-remotes.adoc

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -95,6 +95,7 @@ module.exports = {
9595
----
9696
// Fetch Remote A dynamically:
9797
const fetchRemoteA = (resolve) => {
98+
const fetchRemoteA = (resolve, reject) => {
9899
// We define a script tag to use the browser for fetching the remoteEntry.js file
99100
const script = document.createElement("script");
100101
script.src = window.appAUrl; // This could be defined anywhere
@@ -112,10 +113,14 @@ const fetchRemoteA = (resolve) => {
112113
},
113114
};
114115
resolve(module);
115-
}
116+
};
117+
// Reject promise in case of network error
118+
script.onerror = () => {
119+
reject(new Error('Remote A init error'));
120+
};
116121
// Lastly we inject the script tag into the document's head to trigger the script load
117122
document.head.appendChild(script);
118-
}
123+
};
119124
----
120125

121126
=== Advantages and Limitations

0 commit comments

Comments
 (0)