(signal: NodeJS.Signals | number | null)
| 78 | ) |
| 79 | |
| 80 | const handleSessionStop = async (signal: NodeJS.Signals | number | null) => { |
| 81 | if (signal != null && child?.pid) child.kill(signal) |
| 82 | if (sessionStopHandled) return |
| 83 | sessionStopHandled = true |
| 84 | |
| 85 | // Capture the child's exit code if it has already exited and caused the |
| 86 | // session stop (via the 'exit' event), otherwise assume success (0). |
| 87 | const exitCode = child?.exitCode || 0 |
| 88 | |
| 89 | if ( |
| 90 | signal != null && |
| 91 | child?.pid && |
| 92 | child.exitCode === null && |
| 93 | child.signalCode === null |
| 94 | ) { |
| 95 | let exitTimeout = setTimeout(() => { |
| 96 | child?.kill('SIGKILL') |
| 97 | }, CHILD_EXIT_TIMEOUT_MS) |
| 98 | await once(child, 'exit').catch(() => {}) |
| 99 | clearTimeout(exitTimeout) |
| 100 | } |
| 101 | |
| 102 | sessionSpan.stop() |
| 103 | |
| 104 | try { |
| 105 | const { eventCliSessionStopped } = |
| 106 | require('../telemetry/events/session-stopped') as typeof import('../telemetry/events/session-stopped') |
| 107 | |
| 108 | let pagesDir: boolean = !!traceGlobals.get('pagesDir') |
| 109 | let appDir: boolean = !!traceGlobals.get('appDir') |
| 110 | |
| 111 | if ( |
| 112 | typeof traceGlobals.get('pagesDir') === 'undefined' || |
| 113 | typeof traceGlobals.get('appDir') === 'undefined' |
| 114 | ) { |
| 115 | const pagesResult = findPagesDir(dir) |
| 116 | appDir = !!pagesResult.appDir |
| 117 | pagesDir = !!pagesResult.pagesDir |
| 118 | } |
| 119 | |
| 120 | let telemetry = |
| 121 | (traceGlobals.get('telemetry') as InstanceType< |
| 122 | typeof import('../telemetry/storage').Telemetry |
| 123 | >) || |
| 124 | new Telemetry({ |
| 125 | distDir: path.join(dir, distDir || '.next'), |
| 126 | }) |
| 127 | |
| 128 | telemetry.record( |
| 129 | eventCliSessionStopped({ |
| 130 | cliCommand: 'dev', |
| 131 | turboFlag: isTurbopack, |
| 132 | durationMilliseconds: Date.now() - sessionStarted, |
| 133 | pagesDir, |
| 134 | appDir, |
| 135 | }), |
| 136 | true |
| 137 | ) |
no test coverage detected