@@ -637,6 +637,35 @@ function inspectLockPayloadForSession(params: {
637637 return inspected ;
638638}
639639
640+ function formatSessionLockTimeoutOwner ( params : {
641+ payload : LockFilePayload | null ;
642+ inspected : LockInspectionDetails ;
643+ } ) : string {
644+ const parts = [
645+ params . inspected . pid === null ? "pid=unknown" : `pid=${ params . inspected . pid } ` ,
646+ `alive=${ params . inspected . pidAlive } ` ,
647+ ] ;
648+ if ( typeof params . payload ?. starttime === "number" ) {
649+ parts . push ( `starttime=${ params . payload . starttime } ` ) ;
650+ if ( params . inspected . pid !== null && params . inspected . pidAlive ) {
651+ const currentStarttime = resolveProcessStartTimeForLock ( params . inspected . pid ) ;
652+ parts . push ( `currentStarttime=${ currentStarttime ?? "unknown" } ` ) ;
653+ }
654+ } else {
655+ parts . push ( "starttime=missing" ) ;
656+ }
657+ if ( params . inspected . createdAt ) {
658+ parts . push ( `createdAt=${ params . inspected . createdAt } ` ) ;
659+ }
660+ if ( params . inspected . ageMs !== null ) {
661+ parts . push ( `ageMs=${ params . inspected . ageMs } ` ) ;
662+ }
663+ if ( params . inspected . staleReasons . length > 0 ) {
664+ parts . push ( `staleReasons=${ params . inspected . staleReasons . join ( "," ) } ` ) ;
665+ }
666+ return parts . join ( " " ) ;
667+ }
668+
640669export async function cleanStaleLockFiles ( params : {
641670 sessionsDir : string ;
642671 config ?: SessionWriteLockAcquireTimeoutConfig ;
@@ -783,7 +812,16 @@ export async function acquireSessionWriteLock(params: {
783812 }
784813 const timeoutLockPath = ( err as { lockPath ?: string } ) . lockPath ?? lockPath ;
785814 const payload = await readLockPayload ( timeoutLockPath ) ;
786- const owner = typeof payload ?. pid === "number" ? `pid=${ payload . pid } ` : "unknown" ;
815+ const inspected = inspectLockPayloadForSession ( {
816+ payload,
817+ staleMs,
818+ nowMs : Date . now ( ) ,
819+ heldByThisProcess : sessionLockHeldByThisProcess ( normalizedSessionFile ) ,
820+ reclaimLockWithoutStarttime : true ,
821+ readOwnerProcessArgs : readProcessArgsSync ,
822+ respectMaxHold : true ,
823+ } ) ;
824+ const owner = formatSessionLockTimeoutOwner ( { payload, inspected } ) ;
787825 throw new SessionWriteLockTimeoutError ( { timeoutMs, owner, lockPath : timeoutLockPath } ) ;
788826 }
789827 }
0 commit comments