File tree Expand file tree Collapse file tree 3 files changed +20
-3
lines changed Expand file tree Collapse file tree 3 files changed +20
-3
lines changed Original file line number Diff line number Diff line change
1
+ ---
2
+ ' @module-federation/runtime ' : patch
3
+ ---
4
+
5
+ fix(runtime): catch init remote error in errorLoadRemote hook
Original file line number Diff line number Diff line change @@ -102,7 +102,7 @@ export class RemoteHandler {
102
102
error : unknown ;
103
103
options ?: any ;
104
104
from : CallFrom ;
105
- lifecycle : 'onLoad' | 'beforeRequest' ;
105
+ lifecycle : 'onLoad' | 'beforeRequest' | 'beforeLoadShare' ;
106
106
origin : FederationHost ;
107
107
} ,
108
108
] ,
Original file line number Diff line number Diff line change @@ -305,9 +305,21 @@ export class SharedHandler {
305
305
id : key ,
306
306
} ) ;
307
307
if ( module . getEntry ) {
308
- const entry = await module . getEntry ( ) ;
308
+ let remoteEntryExports : RemoteEntryExports ;
309
+ try {
310
+ remoteEntryExports = await module . getEntry ( ) ;
311
+ } catch ( error ) {
312
+ remoteEntryExports =
313
+ ( await host . remoteHandler . hooks . lifecycle . errorLoadRemote . emit ( {
314
+ id : key ,
315
+ error,
316
+ from : 'runtime' ,
317
+ lifecycle : 'beforeLoadShare' ,
318
+ origin : host ,
319
+ } ) ) as RemoteEntryExports ;
320
+ }
309
321
if ( ! module . inited ) {
310
- await initFn ( entry ) ;
322
+ await initFn ( remoteEntryExports ) ;
311
323
module . inited = true ;
312
324
}
313
325
}
You can’t perform that action at this time.
0 commit comments