File tree Expand file tree Collapse file tree 1 file changed +15
-1
lines changed
playground/environment-react-ssr Expand file tree Collapse file tree 1 file changed +15
-1
lines changed Original file line number Diff line number Diff line change @@ -75,9 +75,23 @@ export function vitePluginSsrMiddleware({
7575 const runner = createServerModuleRunner ( server . environments . ssr , {
7676 hmr : { logger : false } ,
7777 } )
78+ const importWithRetry = async ( ) => {
79+ try {
80+ return await runner . import ( entry )
81+ } catch ( e ) {
82+ if (
83+ e instanceof Error &&
84+ ( e as any ) . code === 'ERR_OUTDATED_OPTIMIZED_DEP'
85+ ) {
86+ runner . clearCache ( )
87+ return await importWithRetry ( )
88+ }
89+ throw e
90+ }
91+ }
7892 const handler : Connect . NextHandleFunction = async ( req , res , next ) => {
7993 try {
80- const mod = await runner . import ( entry )
94+ const mod = await importWithRetry ( )
8195 await mod [ 'default' ] ( req , res , next )
8296 } catch ( e ) {
8397 next ( e )
You can’t perform that action at this time.
0 commit comments