@@ -263,26 +263,6 @@ const respawnWithPackagedCompileCacheIfNeeded = () => {
263263 ) ;
264264} ;
265265
266- // Codex owns the relay timeout by PID. Keep the launcher as that exact process
267- // so a timeout cannot strand a compile-cache respawn child.
268- const waitingForCompileCacheRespawn =
269- ! ( process . platform !== "win32" && isNativeHookRelayInvocation ( process . argv ) ) &&
270- ( respawnWithoutCompileCacheIfNeeded ( ) || respawnWithPackagedCompileCacheIfNeeded ( ) ) ;
271-
272- // https://nodejs.org/api/module.html#module-compile-cache
273- if (
274- ! waitingForCompileCacheRespawn &&
275- module . enableCompileCache &&
276- ! isNodeCompileCacheDisabled ( ) &&
277- ! isSourceCheckoutLauncher ( )
278- ) {
279- try {
280- module . enableCompileCache ( resolvePackagedCompileCacheDirectory ( ) ) ;
281- } catch {
282- // Ignore errors
283- }
284- }
285-
286266const getErrorMessage = ( err ) =>
287267 err && typeof err === "object" && "message" in err && typeof err . message === "string"
288268 ? err . message
@@ -427,6 +407,24 @@ const consumeLauncherRootOptionToken = (args, index) => {
427407 return 0 ;
428408} ;
429409
410+ // Mirror the entry's foreground Gmail policy before any built modules can load.
411+ // A compile-cache wrapper would kill its owner before descendant cleanup finishes.
412+ const isForegroundGmailRunInvocation = ( argv ) => {
413+ const args = argv . slice ( 2 ) ;
414+ const commandPath = [ ] ;
415+ for ( let index = 0 ; index < args . length && commandPath . length < 3 ; index += 1 ) {
416+ const consumed = consumeLauncherRootOptionToken ( args , index ) ;
417+ if ( consumed > 0 ) {
418+ index += consumed - 1 ;
419+ } else if ( ! args [ index ] || args [ index ] . startsWith ( "-" ) ) {
420+ break ;
421+ } else {
422+ commandPath . push ( args [ index ] ) ;
423+ }
424+ }
425+ return commandPath . join ( " " ) === "webhooks gmail run" ;
426+ } ;
427+
430428const hasLauncherContainerTarget = ( argv ) => {
431429 if ( normalizeLauncherMetadataValue ( process . env . OPENCLAW_CONTAINER ) ) {
432430 return true ;
@@ -769,6 +767,27 @@ const tryOutputPrecomputedCommandHelp = () => {
769767 return true ;
770768} ;
771769
770+ // Codex owns the relay timeout by PID. Keep the launcher as that exact process
771+ // so a timeout cannot strand a compile-cache respawn child.
772+ const waitingForCompileCacheRespawn =
773+ ! isForegroundGmailRunInvocation ( process . argv ) &&
774+ ! ( process . platform !== "win32" && isNativeHookRelayInvocation ( process . argv ) ) &&
775+ ( respawnWithoutCompileCacheIfNeeded ( ) || respawnWithPackagedCompileCacheIfNeeded ( ) ) ;
776+
777+ // https://nodejs.org/api/module.html#module-compile-cache
778+ if (
779+ ! waitingForCompileCacheRespawn &&
780+ module . enableCompileCache &&
781+ ! isNodeCompileCacheDisabled ( ) &&
782+ ! isSourceCheckoutLauncher ( )
783+ ) {
784+ try {
785+ module . enableCompileCache ( resolvePackagedCompileCacheDirectory ( ) ) ;
786+ } catch {
787+ // Ignore errors
788+ }
789+ }
790+
772791if ( ! waitingForCompileCacheRespawn ) {
773792 if ( ! isHelpFastPathDisabled ( ) && ( await tryOutputBareRootHelp ( ) ) ) {
774793 // OK
0 commit comments