File tree Expand file tree Collapse file tree 1 file changed +15
-2
lines changed
Expand file tree Collapse file tree 1 file changed +15
-2
lines changed Original file line number Diff line number Diff line change @@ -59,6 +59,7 @@ import {
5959 mergeWithDefaults ,
6060 normalizePath ,
6161 partialEncodeURIPath ,
62+ setupSIGTERMListener ,
6263 unique ,
6364} from './utils'
6465import { perEnvironmentPlugin , resolveEnvironmentPlugins } from './plugin'
@@ -973,8 +974,20 @@ async function buildEnvironment(
973974 }
974975 throw e
975976 } finally {
976- // close the bundle will make the rolldown hmr invalid, so dev build need to disable it.
977- if ( bundle && ! server ) await bundle . close ( )
977+ // Note: close the bundle will make the rolldown hmr invalid, so dev build need to disable it.
978+ if ( server ) {
979+ const closeBundleAndExit = async ( _ : unknown , exitCode ?: number ) => {
980+ try {
981+ if ( bundle ) await bundle . close ( )
982+ } finally {
983+ process . exitCode ??= exitCode ? 128 + exitCode : undefined
984+ process . exit ( )
985+ }
986+ }
987+ setupSIGTERMListener ( closeBundleAndExit )
988+ } else {
989+ if ( bundle ) await bundle . close ( )
990+ }
978991 }
979992}
980993
You can’t perform that action at this time.
0 commit comments