Unverified Commit 535ac3cf authored by Will Binns-Smith's avatar Will Binns-Smith Committed by GitHub

trace: detect rage restarts and deleted .next dirs (#92489)

**This is only sent if there is an explicit, user-provided
`--experimental-upload-trace` set.**

Adds two new attributes to the `start-dev-server` span when
`--experimental-upload-trace` is set:

- `rage-restart` — true if the server was restarted within 2 minutes of
last stopping
- `missing-next-dir` — true if the `.next` dir from the previous session
was deleted before restart

State (stop time + dist dir path) is written to a temp file outside
`.next` on graceful shutdown, so it survives `rm -rf .next`. Detection
results are passed to the child via `NEXT_PRIVATE_DEV_SPAN_ATTRS`,
following the same pattern as `NEXT_PRIVATE_ENABLED_FEATURES`.

Test Plan: Added an e2e test.

<!-- NEXT_JS_LLM_PR -->

---------
Co-authored-by: 's avatarWill Binns-Smith <wbinnssmith@users.noreply.github.com>
Co-authored-by: 's avatarClaude <noreply@anthropic.com>
parent f98a3f11
...@@ -352,6 +352,7 @@ ...@@ -352,6 +352,7 @@
"webpack": "5.98.0", "webpack": "5.98.0",
"webpack-sources1": "npm:webpack-sources@1.4.3", "webpack-sources1": "npm:webpack-sources@1.4.3",
"webpack-sources3": "npm:webpack-sources@3.2.3", "webpack-sources3": "npm:webpack-sources@3.2.3",
"write-file-atomic": "7.0.1",
"ws": "8.2.3", "ws": "8.2.3",
"zod": "3.25.76", "zod": "3.25.76",
"zod-validation-error": "3.4.0" "zod-validation-error": "3.4.0"
......
...@@ -32,7 +32,9 @@ import { ...@@ -32,7 +32,9 @@ import {
getReservedPortExplanation, getReservedPortExplanation,
isPortIsReserved, isPortIsReserved,
} from '../lib/helpers/get-reserved-port' } from '../lib/helpers/get-reserved-port'
import { getCacheDirectory } from '../lib/helpers/get-cache-directory'
import os from 'os' import os from 'os'
import fs from 'node:fs'
import { once } from 'node:events' import { once } from 'node:events'
import { clearTimeout } from 'timers' import { clearTimeout } from 'timers'
import { trace, initializeTraceState, exportTraceState } from '../trace' import { trace, initializeTraceState, exportTraceState } from '../trace'
...@@ -68,9 +70,22 @@ let distDir: string | undefined ...@@ -68,9 +70,22 @@ let distDir: string | undefined
let isTurbopack: boolean let isTurbopack: boolean
let traceUploadUrl: string let traceUploadUrl: string
let sessionStopHandled = false let sessionStopHandled = false
let devSpanAttrs: { 'rage-restart': boolean; 'missing-next-dir': boolean } = {
'rage-restart': false,
'missing-next-dir': false,
}
const sessionStarted = Date.now() const sessionStarted = Date.now()
const sessionSpan = trace('next-dev') const sessionSpan = trace('next-dev')
// If the user restarts the dev server within this window we count it as a "rage restart".
const RAGE_RESTART_THRESHOLD_MS = 120_000
// Single shared file for all projects — keyed by project directory path.
const DEV_STATE_FILE = path.join(
getCacheDirectory('nextjs-nodejs'),
'dev-state.json'
)
// How long should we wait for the child to cleanly exit after sending // How long should we wait for the child to cleanly exit after sending
// SIGINT/SIGTERM to the child process before sending SIGKILL? // SIGINT/SIGTERM to the child process before sending SIGKILL?
const CHILD_EXIT_TIMEOUT_MS = parseInt( const CHILD_EXIT_TIMEOUT_MS = parseInt(
...@@ -118,7 +133,7 @@ const handleSessionStop = async (signal: NodeJS.Signals | number | null) => { ...@@ -118,7 +133,7 @@ const handleSessionStop = async (signal: NodeJS.Signals | number | null) => {
pagesDir = !!pagesResult.pagesDir pagesDir = !!pagesResult.pagesDir
} }
let telemetry = const telemetry =
(traceGlobals.get('telemetry') as InstanceType< (traceGlobals.get('telemetry') as InstanceType<
typeof import('../telemetry/storage').Telemetry typeof import('../telemetry/storage').Telemetry
>) || >) ||
...@@ -150,6 +165,8 @@ const handleSessionStop = async (signal: NodeJS.Signals | number | null) => { ...@@ -150,6 +165,8 @@ const handleSessionStop = async (signal: NodeJS.Signals | number | null) => {
distDir, distDir,
isTurboSession: isTurbopack, isTurboSession: isTurbopack,
}) })
writeDevState()
} }
// Save CPU profile if it was enabled (before exiting) // Save CPU profile if it was enabled (before exiting)
...@@ -166,7 +183,14 @@ process.on('SIGINT', () => handleSessionStop('SIGINT')) ...@@ -166,7 +183,14 @@ process.on('SIGINT', () => handleSessionStop('SIGINT'))
process.on('SIGTERM', () => handleSessionStop('SIGTERM')) process.on('SIGTERM', () => handleSessionStop('SIGTERM'))
// exit event must be synchronous // exit event must be synchronous
process.on('exit', () => child?.kill('SIGKILL')) process.on('exit', () => {
child?.kill('SIGKILL')
// Catch aggressive kills (e.g. OOM, unhandled exception) that bypass handleSessionStop.
// SIGKILL of the parent cannot be caught; for all other exits this ensures state is written.
if (!sessionStopHandled) {
writeDevState()
}
})
const nextDev = async ( const nextDev = async (
options: NextDevOptions, options: NextDevOptions,
...@@ -248,6 +272,34 @@ const nextDev = async ( ...@@ -248,6 +272,34 @@ const nextDev = async (
traceUploadUrl = options.experimentalUploadTrace traceUploadUrl = options.experimentalUploadTrace
} }
if (traceUploadUrl) {
let isRageRestart = false
let distDirCleared = false
try {
if (fs.existsSync(DEV_STATE_FILE)) {
const allState = JSON.parse(
fs.readFileSync(DEV_STATE_FILE, 'utf8')
) as Record<string, { stopTime?: number; distDirPath?: string }>
const state = allState[dir]
if (
state?.stopTime &&
Date.now() - state.stopTime < RAGE_RESTART_THRESHOLD_MS
) {
isRageRestart = true
}
if (state?.distDirPath && !fs.existsSync(state.distDirPath)) {
distDirCleared = true
}
}
} catch {
// Corrupt file — leave both flags false
}
devSpanAttrs = {
'rage-restart': isRageRestart,
'missing-next-dir': distDirCleared,
}
}
const enabledFeatures = Object.fromEntries( const enabledFeatures = Object.fromEntries(
Object.entries({ Object.entries({
serverFastRefreshDisabled: options.serverFastRefresh === false, serverFastRefreshDisabled: options.serverFastRefresh === false,
...@@ -332,6 +384,7 @@ const nextDev = async ( ...@@ -332,6 +384,7 @@ const nextDev = async (
NEXT_PRIVATE_WORKER: '1', NEXT_PRIVATE_WORKER: '1',
NEXT_PRIVATE_TRACE_ID: traceId, NEXT_PRIVATE_TRACE_ID: traceId,
NEXT_PRIVATE_ENABLED_FEATURES: JSON.stringify(enabledFeatures), NEXT_PRIVATE_ENABLED_FEATURES: JSON.stringify(enabledFeatures),
NEXT_PRIVATE_DEV_SPAN_ATTRS: JSON.stringify(devSpanAttrs),
NODE_EXTRA_CA_CERTS: startServerOptions.selfSignedCertificate NODE_EXTRA_CA_CERTS: startServerOptions.selfSignedCertificate
? startServerOptions.selfSignedCertificate.rootCA ? startServerOptions.selfSignedCertificate.rootCA
: defaultEnv.NODE_EXTRA_CA_CERTS, : defaultEnv.NODE_EXTRA_CA_CERTS,
...@@ -449,4 +502,41 @@ const nextDev = async ( ...@@ -449,4 +502,41 @@ const nextDev = async (
await runDevServer(false) await runDevServer(false)
} }
function writeDevState(): void {
if (!traceUploadUrl || !dir) return
try {
fs.mkdirSync(path.dirname(DEV_STATE_FILE), { recursive: true })
let state: Record<string, { stopTime: number; distDirPath: string }> = {}
try {
state = JSON.parse(fs.readFileSync(DEV_STATE_FILE, 'utf8'))
} catch {
// File missing or corrupt — start with empty state
}
// Eagerly remove entries that are stale (older than threshold) or invalid
// (future timestamps from clock skew or corruption).
const now = Date.now()
const cutoff = now - RAGE_RESTART_THRESHOLD_MS
for (const key of Object.keys(state)) {
const t = state[key]?.stopTime
if (!t || t < cutoff || t > now) {
delete state[key]
}
}
// Update current project
state[dir] = {
stopTime: Date.now(),
distDirPath: path.join(dir, distDir ?? '.next'),
}
const { sync: writeFileAtomicSync } =
require('next/dist/compiled/write-file-atomic') as typeof import('next/dist/compiled/write-file-atomic')
writeFileAtomicSync(DEV_STATE_FILE, JSON.stringify(state))
} catch {
// Best effort — don't interfere with shutdown
}
}
export { nextDev } export { nextDev }
This source diff could not be displayed because it is too large. You can view the blob instead.
Copyright (c) 2015, Rebecca Turner
Permission to use, copy, modify, and/or distribute this software for any purpose with or without fee is hereby granted, provided that the above copyright notice and this permission notice appear in all copies.
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
(()=>{"use strict";var e={753:(e,t,i)=>{e.exports=writeFile;e.exports.sync=writeFileSync;e.exports._getTmpname=getTmpname;e.exports._cleanupOnExit=cleanupOnExit;const s=i(147);const n=i(5);const{onExit:r}=i(907);const o=i(17);const{promisify:c}=i(837);const a={};const l=function getId(){try{const e=i(267);return e.threadId}catch(e){return 0}}();let f=0;function getTmpname(e){return e+"."+n.createHash("sha1").update(__filename).update(String(process.pid)).update(String(l)).update(String(++f)).digest().readUInt32BE(0)}function cleanupOnExit(e){return()=>{try{s.unlinkSync(typeof e==="function"?e():e)}catch{}}}function serializeActiveFile(e){return new Promise((t=>{if(!a[e]){a[e]=[]}a[e].push(t);if(a[e].length===1){t()}}))}function isChownErrOk(e){if(e.code==="ENOSYS"){return true}const t=!process.getuid||process.getuid()!==0;if(t){if(e.code==="EINVAL"||e.code==="EPERM"){return true}}return false}async function writeFileAsync(e,t,i={}){if(typeof i==="string"){i={encoding:i}}let n;let l;const f=r(cleanupOnExit((()=>l)));const u=o.resolve(e);try{await serializeActiveFile(u);const r=await c(s.realpath)(e).catch((()=>e));l=getTmpname(r);if(!i.mode||!i.chown){const e=await c(s.stat)(r).catch((()=>{}));if(e){if(i.mode==null){i.mode=e.mode}if(i.chown==null&&process.getuid){i.chown={uid:e.uid,gid:e.gid}}}}n=await c(s.open)(l,"w",i.mode);if(i.tmpfileCreated){await i.tmpfileCreated(l)}if(ArrayBuffer.isView(t)){await c(s.write)(n,t,0,t.length,0)}else if(t!=null){await c(s.write)(n,String(t),0,String(i.encoding||"utf8"))}if(i.fsync!==false){await c(s.fsync)(n)}await c(s.close)(n);n=null;if(i.chown){await c(s.chown)(l,i.chown.uid,i.chown.gid).catch((e=>{if(!isChownErrOk(e)){throw e}}))}if(i.mode){await c(s.chmod)(l,i.mode).catch((e=>{if(!isChownErrOk(e)){throw e}}))}await c(s.rename)(l,r)}finally{if(n){await c(s.close)(n).catch((()=>{}))}f();await c(s.unlink)(l).catch((()=>{}));a[u].shift();if(a[u].length>0){a[u][0]()}else{delete a[u]}}}async function writeFile(e,t,i,s){if(i instanceof Function){s=i;i={}}const n=writeFileAsync(e,t,i);if(s){try{const e=await n;return s(e)}catch(e){return s(e)}}return n}function writeFileSync(e,t,i){if(typeof i==="string"){i={encoding:i}}else if(!i){i={}}try{e=s.realpathSync(e)}catch(e){}const n=getTmpname(e);if(!i.mode||!i.chown){try{const t=s.statSync(e);i=Object.assign({},i);if(!i.mode){i.mode=t.mode}if(!i.chown&&process.getuid){i.chown={uid:t.uid,gid:t.gid}}}catch(e){}}let o;const c=cleanupOnExit(n);const a=r(c);let l=true;try{o=s.openSync(n,"w",i.mode||438);if(i.tmpfileCreated){i.tmpfileCreated(n)}if(ArrayBuffer.isView(t)){s.writeSync(o,t,0,t.length,0)}else if(t!=null){s.writeSync(o,String(t),0,String(i.encoding||"utf8"))}if(i.fsync!==false){s.fsyncSync(o)}s.closeSync(o);o=null;if(i.chown){try{s.chownSync(n,i.chown.uid,i.chown.gid)}catch(e){if(!isChownErrOk(e)){throw e}}}if(i.mode){try{s.chmodSync(n,i.mode)}catch(e){if(!isChownErrOk(e)){throw e}}}s.renameSync(n,e);l=false}finally{if(o){try{s.closeSync(o)}catch(e){}}a();if(l){c()}}}},147:e=>{e.exports=require("fs")},5:e=>{e.exports=require("node:crypto")},17:e=>{e.exports=require("path")},837:e=>{e.exports=require("util")},267:e=>{e.exports=require("worker_threads")},907:(e,t,i)=>{var s;Object.defineProperty(t,"__esModule",{value:true});t.unload=t.load=t.onExit=t.signals=void 0;const n=i(79);Object.defineProperty(t,"signals",{enumerable:true,get:function(){return n.signals}});const processOk=e=>!!e&&typeof e==="object"&&typeof e.removeListener==="function"&&typeof e.emit==="function"&&typeof e.reallyExit==="function"&&typeof e.listeners==="function"&&typeof e.kill==="function"&&typeof e.pid==="number"&&typeof e.on==="function";const r=Symbol.for("signal-exit emitter");const o=globalThis;const c=Object.defineProperty.bind(Object);class Emitter{emitted={afterExit:false,exit:false};listeners={afterExit:[],exit:[]};count=0;id=Math.random();constructor(){if(o[r]){return o[r]}c(o,r,{value:this,writable:false,enumerable:false,configurable:false})}on(e,t){this.listeners[e].push(t)}removeListener(e,t){const i=this.listeners[e];const s=i.indexOf(t);if(s===-1){return}if(s===0&&i.length===1){i.length=0}else{i.splice(s,1)}}emit(e,t,i){if(this.emitted[e]){return false}this.emitted[e]=true;let s=false;for(const n of this.listeners[e]){s=n(t,i)===true||s}if(e==="exit"){s=this.emit("afterExit",t,i)||s}return s}}class SignalExitBase{}const signalExitWrap=e=>({onExit(t,i){return e.onExit(t,i)},load(){return e.load()},unload(){return e.unload()}});class SignalExitFallback extends SignalExitBase{onExit(){return()=>{}}load(){}unload(){}}class SignalExit extends SignalExitBase{#e=a.platform==="win32"?"SIGINT":"SIGHUP";#t=new Emitter;#i;#s;#n;#r={};#o=false;constructor(e){super();this.#i=e;this.#r={};for(const t of n.signals){this.#r[t]=()=>{const i=this.#i.listeners(t);let{count:s}=this.#t;const n=e;if(typeof n.__signal_exit_emitter__==="object"&&typeof n.__signal_exit_emitter__.count==="number"){s+=n.__signal_exit_emitter__.count}if(i.length===s){this.unload();const i=this.#t.emit("exit",null,t);const s=t==="SIGHUP"?this.#e:t;if(!i)e.kill(e.pid,s)}}}this.#n=e.reallyExit;this.#s=e.emit}onExit(e,t){if(!processOk(this.#i)){return()=>{}}if(this.#o===false){this.load()}const i=t?.alwaysLast?"afterExit":"exit";this.#t.on(i,e);return()=>{this.#t.removeListener(i,e);if(this.#t.listeners["exit"].length===0&&this.#t.listeners["afterExit"].length===0){this.unload()}}}load(){if(this.#o){return}this.#o=true;this.#t.count+=1;for(const e of n.signals){try{const t=this.#r[e];if(t)this.#i.on(e,t)}catch(e){}}this.#i.emit=(e,...t)=>this.#c(e,...t);this.#i.reallyExit=e=>this.#a(e)}unload(){if(!this.#o){return}this.#o=false;n.signals.forEach((e=>{const t=this.#r[e];if(!t){throw new Error("Listener not defined for signal: "+e)}try{this.#i.removeListener(e,t)}catch(e){}}));this.#i.emit=this.#s;this.#i.reallyExit=this.#n;this.#t.count-=1}#a(e){if(!processOk(this.#i)){return 0}this.#i.exitCode=e||0;this.#t.emit("exit",this.#i.exitCode,null);return this.#n.call(this.#i,this.#i.exitCode)}#c(e,...t){const i=this.#s;if(e==="exit"&&processOk(this.#i)){if(typeof t[0]==="number"){this.#i.exitCode=t[0]}const s=i.call(this.#i,e,...t);this.#t.emit("exit",this.#i.exitCode,null);return s}else{return i.call(this.#i,e,...t)}}}const a=globalThis.process;s=signalExitWrap(processOk(a)?new SignalExit(a):new SignalExitFallback),t.onExit=s.onExit,t.load=s.load,t.unload=s.unload},79:(e,t)=>{Object.defineProperty(t,"__esModule",{value:true});t.signals=void 0;t.signals=[];t.signals.push("SIGHUP","SIGINT","SIGTERM");if(process.platform!=="win32"){t.signals.push("SIGALRM","SIGABRT","SIGVTALRM","SIGXCPU","SIGXFSZ","SIGUSR2","SIGTRAP","SIGSYS","SIGQUIT","SIGIOT")}if(process.platform==="linux"){t.signals.push("SIGIO","SIGPOLL","SIGPWR","SIGSTKFLT")}}};var t={};function __nccwpck_require__(i){var s=t[i];if(s!==undefined){return s.exports}var n=t[i]={exports:{}};var r=true;try{e[i](n,n.exports,__nccwpck_require__);r=false}finally{if(r)delete t[i]}return n.exports}if(typeof __nccwpck_require__!=="undefined")__nccwpck_require__.ab=__dirname+"/";var i=__nccwpck_require__(753);module.exports=i})();
\ No newline at end of file
{"name":"write-file-atomic","main":"index.js","author":"GitHub Inc.","license":"ISC"}
...@@ -599,6 +599,13 @@ if (process.env.NEXT_PRIVATE_WORKER && process.send) { ...@@ -599,6 +599,13 @@ if (process.env.NEXT_PRIVATE_WORKER && process.send) {
) )
} }
let rageRestartAttrsFromParent = {}
if (process.env.NEXT_PRIVATE_DEV_SPAN_ATTRS) {
rageRestartAttrsFromParent = JSON.parse(
process.env.NEXT_PRIVATE_DEV_SPAN_ATTRS
)
}
startServerSpan = trace('start-dev-server', undefined, { startServerSpan = trace('start-dev-server', undefined, {
cpus: String(os.cpus().length), cpus: String(os.cpus().length),
platform: os.platform(), platform: os.platform(),
...@@ -606,6 +613,7 @@ if (process.env.NEXT_PRIVATE_WORKER && process.send) { ...@@ -606,6 +613,7 @@ if (process.env.NEXT_PRIVATE_WORKER && process.send) {
'memory.totalMem': String(os.totalmem()), 'memory.totalMem': String(os.totalmem()),
'memory.heapSizeLimit': String(v8.getHeapStatistics().heap_size_limit), 'memory.heapSizeLimit': String(v8.getHeapStatistics().heap_size_limit),
...enabledFeaturesFromParent, ...enabledFeaturesFromParent,
...rageRestartAttrsFromParent,
}) })
initializeTraceState({ initializeTraceState({
......
...@@ -2109,6 +2109,14 @@ export async function ncc_webpack_bundle_packages(task, opts) { ...@@ -2109,6 +2109,14 @@ export async function ncc_webpack_bundle_packages(task, opts) {
.target('src/compiled/webpack/') .target('src/compiled/webpack/')
} }
externals['write-file-atomic'] = 'next/dist/compiled/write-file-atomic'
export async function ncc_write_file_atomic(task, opts) {
await task
.source(relative(__dirname, require.resolve('write-file-atomic')))
.ncc({ packageName: 'write-file-atomic', externals })
.target('src/compiled/write-file-atomic')
}
externals['ws'] = 'next/dist/compiled/ws' externals['ws'] = 'next/dist/compiled/ws'
export async function ncc_ws(task, opts) { export async function ncc_ws(task, opts) {
await task await task
...@@ -2320,6 +2328,7 @@ export async function ncc(task, opts) { ...@@ -2320,6 +2328,7 @@ export async function ncc(task, opts) {
'ncc_webpack_bundle5', 'ncc_webpack_bundle5',
'ncc_webpack_sources1', 'ncc_webpack_sources1',
'ncc_webpack_sources3', 'ncc_webpack_sources3',
'ncc_write_file_atomic',
'ncc_ws', 'ncc_ws',
'ncc_ua_parser_js', 'ncc_ua_parser_js',
'ncc_minimatch', 'ncc_minimatch',
......
...@@ -806,6 +806,16 @@ declare module 'next/dist/compiled/web-vitals' { ...@@ -806,6 +806,16 @@ declare module 'next/dist/compiled/web-vitals' {
} }
declare module 'next/dist/compiled/web-vitals-attribution' {} declare module 'next/dist/compiled/web-vitals-attribution' {}
declare module 'next/dist/compiled/write-file-atomic' {
function writeFileAtomicSync(
filename: string,
data: string | Buffer,
options?: { mode?: number; chown?: { uid: number; gid: number } }
): void
export const sync: typeof writeFileAtomicSync
export default writeFileAtomicSync
}
declare module 'next/dist/compiled/ws' { declare module 'next/dist/compiled/ws' {
import m from 'ws' import m from 'ws'
export = m export = m
......
...@@ -1778,6 +1778,9 @@ importers: ...@@ -1778,6 +1778,9 @@ importers:
webpack-sources3: webpack-sources3:
specifier: npm:webpack-sources@3.2.3 specifier: npm:webpack-sources@3.2.3
version: webpack-sources@3.2.3(patch_hash=26afc15966a3fc37a3d1d366312a95ce66723513f6a3a720e4166a37147da8bd) version: webpack-sources@3.2.3(patch_hash=26afc15966a3fc37a3d1d366312a95ce66723513f6a3a720e4166a37147da8bd)
write-file-atomic:
specifier: 7.0.1
version: 7.0.1
ws: ws:
specifier: 8.2.3 specifier: 8.2.3
version: 8.2.3 version: 8.2.3
...@@ -11248,15 +11251,15 @@ packages: ...@@ -11248,15 +11251,15 @@ packages:
glob@7.1.6: glob@7.1.6:
resolution: {integrity: sha512-LwaxwyZ72Lk7vZINtNNrywX0ZuLyStrdDtabefZKAY5ZGJhVtgdznluResxNmPitE0SAO+O26sWTHeKSI2wMBA==} resolution: {integrity: sha512-LwaxwyZ72Lk7vZINtNNrywX0ZuLyStrdDtabefZKAY5ZGJhVtgdznluResxNmPitE0SAO+O26sWTHeKSI2wMBA==}
deprecated: Glob versions prior to v9 are no longer supported deprecated: Old versions of glob are not supported, and contain widely publicized security vulnerabilities, which have been fixed in the current version. Please update. Support for old versions may be purchased (at exorbitant rates) by contacting i@izs.me
glob@7.1.7: glob@7.1.7:
resolution: {integrity: sha512-OvD9ENzPLbegENnYP5UUfJIirTg4+XwMWGaQfQTY0JenxNvvIKP3U3/tAQSPIu/lHxXYSZmpXlUHeqAIdKzBLQ==} resolution: {integrity: sha512-OvD9ENzPLbegENnYP5UUfJIirTg4+XwMWGaQfQTY0JenxNvvIKP3U3/tAQSPIu/lHxXYSZmpXlUHeqAIdKzBLQ==}
deprecated: Glob versions prior to v9 are no longer supported deprecated: Old versions of glob are not supported, and contain widely publicized security vulnerabilities, which have been fixed in the current version. Please update. Support for old versions may be purchased (at exorbitant rates) by contacting i@izs.me
glob@7.2.3: glob@7.2.3:
resolution: {integrity: sha512-nFR0zLpU2YCaRxwoCJvL6UvCH2JFyFVIvwTLsIf21AuHlMskA1hhTdk+LlYJtOlYt9v6dvszD2BGRqBL+iQK9Q==} resolution: {integrity: sha512-nFR0zLpU2YCaRxwoCJvL6UvCH2JFyFVIvwTLsIf21AuHlMskA1hhTdk+LlYJtOlYt9v6dvszD2BGRqBL+iQK9Q==}
deprecated: Glob versions prior to v9 are no longer supported deprecated: Old versions of glob are not supported, and contain widely publicized security vulnerabilities, which have been fixed in the current version. Please update. Support for old versions may be purchased (at exorbitant rates) by contacting i@izs.me
glob@9.3.5: glob@9.3.5:
resolution: {integrity: sha512-e1LleDykUz2Iu+MTYdkSsuWX8lvAjAcs0Xef0lNIu0S2wOAzuTxCJtcd9S3cijlwYF18EsU3rzb8jPVobxDh9Q==} resolution: {integrity: sha512-e1LleDykUz2Iu+MTYdkSsuWX8lvAjAcs0Xef0lNIu0S2wOAzuTxCJtcd9S3cijlwYF18EsU3rzb8jPVobxDh9Q==}
...@@ -16043,6 +16046,7 @@ packages: ...@@ -16043,6 +16046,7 @@ packages:
engines: {node: '>=0.6.0', teleport: '>=0.2.0'} engines: {node: '>=0.6.0', teleport: '>=0.2.0'}
deprecated: |- deprecated: |-
You or someone you depend on is using Q, the JavaScript Promise library that gave JavaScript developers strong feelings about promises. They can almost certainly migrate to the native JavaScript promise now. Thank you literally everyone for joining me in this bet against the odds. Be excellent to each other. You or someone you depend on is using Q, the JavaScript Promise library that gave JavaScript developers strong feelings about promises. They can almost certainly migrate to the native JavaScript promise now. Thank you literally everyone for joining me in this bet against the odds. Be excellent to each other.
(For a CapTP with native promises, see @endo/eventual-send and @endo/captp) (For a CapTP with native promises, see @endo/eventual-send and @endo/captp)
qs@6.11.0: qs@6.11.0:
...@@ -17627,7 +17631,7 @@ packages: ...@@ -17627,7 +17631,7 @@ packages:
superagent@3.8.3: superagent@3.8.3:
resolution: {integrity: sha512-GLQtLMCoEIK4eDv6OGtkOoSMt3D+oq0y3dsxMuYuDvaNUvuT8eFBuLmfR0iYYzHC1e8hpzC6ZsxbuP6DIalMFA==} resolution: {integrity: sha512-GLQtLMCoEIK4eDv6OGtkOoSMt3D+oq0y3dsxMuYuDvaNUvuT8eFBuLmfR0iYYzHC1e8hpzC6ZsxbuP6DIalMFA==}
engines: {node: '>= 4.0'} engines: {node: '>= 4.0'}
deprecated: Please upgrade to v7.0.2+ of superagent. We have fixed numerous issues with streams, form-data, attach(), filesystem errors not bubbling up (ENOENT on attach()), and all tests are now passing. See the releases tab for more information at <https://github.com/visionmedia/superagent/releases>. deprecated: Please upgrade to superagent v10.2.2+, see release notes at https://github.com/forwardemail/superagent/releases/tag/v10.2.2 - maintenance is supported by Forward Email @ https://forwardemail.net
superstruct@1.0.3: superstruct@1.0.3:
resolution: {integrity: sha512-8iTn3oSS8nRGn+C2pgXSKPI3jmpm6FExNazNpjvqS6ZUJQCej3PUXEKM8NjHBOs54ExM+LPW/FBRhymrdcCiSg==} resolution: {integrity: sha512-8iTn3oSS8nRGn+C2pgXSKPI3jmpm6FExNazNpjvqS6ZUJQCej3PUXEKM8NjHBOs54ExM+LPW/FBRhymrdcCiSg==}
...@@ -19035,6 +19039,10 @@ packages: ...@@ -19035,6 +19039,10 @@ packages:
resolution: {integrity: sha512-GmqrO8WJ1NuzJ2DrziEI2o57jKAVIQNf8a18W3nCYU3H7PNWqCCVTeH6/NQE93CIllIgQS98rrmVkYgTX9fFJQ==} resolution: {integrity: sha512-GmqrO8WJ1NuzJ2DrziEI2o57jKAVIQNf8a18W3nCYU3H7PNWqCCVTeH6/NQE93CIllIgQS98rrmVkYgTX9fFJQ==}
engines: {node: ^18.17.0 || >=20.5.0} engines: {node: ^18.17.0 || >=20.5.0}
write-file-atomic@7.0.1:
resolution: {integrity: sha512-OTIk8iR8/aCRWBqvxrzxR0hgxWpnYBblY1S5hDWBQfk/VFmJwzmJgQFN3WsoUKHISv2eAwe+PpbUzyL1CKTLXg==}
engines: {node: ^20.17.0 || >=22.9.0}
write-json-file@3.2.0: write-json-file@3.2.0:
resolution: {integrity: sha512-3xZqT7Byc2uORAatYiP3DHUUAVEkNOswEWNs9H5KXiicRTvzYzYqKjYc4G7p+8pltvAw641lVByKVtMpf+4sYQ==} resolution: {integrity: sha512-3xZqT7Byc2uORAatYiP3DHUUAVEkNOswEWNs9H5KXiicRTvzYzYqKjYc4G7p+8pltvAw641lVByKVtMpf+4sYQ==}
engines: {node: '>=6'} engines: {node: '>=6'}
...@@ -28494,8 +28502,8 @@ snapshots: ...@@ -28494,8 +28502,8 @@ snapshots:
'@next/eslint-plugin-next': 16.2.0-canary.91 '@next/eslint-plugin-next': 16.2.0-canary.91
eslint: 9.37.0(jiti@2.6.1) eslint: 9.37.0(jiti@2.6.1)
eslint-import-resolver-node: 0.3.9 eslint-import-resolver-node: 0.3.9
eslint-import-resolver-typescript: 3.10.1(eslint-plugin-import-x@4.3.1(eslint@9.37.0(jiti@2.6.1))(typescript@5.9.2))(eslint-plugin-import@2.32.0)(eslint@9.37.0(jiti@2.6.1)) eslint-import-resolver-typescript: 3.10.1(eslint-plugin-import-x@4.3.1(eslint@9.37.0(jiti@2.6.1))(typescript@5.9.2))(eslint-plugin-import@2.32.0(eslint@9.37.0(jiti@2.6.1)))(eslint@9.37.0(jiti@2.6.1))
eslint-plugin-import: 2.32.0(eslint-import-resolver-typescript@3.10.1)(eslint@9.37.0(jiti@2.6.1)) eslint-plugin-import: 2.32.0(eslint-import-resolver-typescript@3.10.1(eslint-plugin-import-x@4.3.1(eslint@9.37.0(jiti@2.6.1))(typescript@5.9.2))(eslint-plugin-import@2.32.0(eslint@9.37.0(jiti@2.6.1)))(eslint@9.37.0(jiti@2.6.1)))(eslint@9.37.0(jiti@2.6.1))
eslint-plugin-jsx-a11y: 6.10.2(eslint@9.37.0(jiti@2.6.1)) eslint-plugin-jsx-a11y: 6.10.2(eslint@9.37.0(jiti@2.6.1))
eslint-plugin-react: 7.37.0(eslint@9.37.0(jiti@2.6.1)) eslint-plugin-react: 7.37.0(eslint@9.37.0(jiti@2.6.1))
eslint-plugin-react-hooks: 7.0.0(eslint@9.37.0(jiti@2.6.1)) eslint-plugin-react-hooks: 7.0.0(eslint@9.37.0(jiti@2.6.1))
...@@ -28522,6 +28530,22 @@ snapshots: ...@@ -28522,6 +28530,22 @@ snapshots:
transitivePeerDependencies: transitivePeerDependencies:
- supports-color - supports-color
eslint-import-resolver-typescript@3.10.1(eslint-plugin-import-x@4.3.1(eslint@9.37.0(jiti@2.6.1))(typescript@5.9.2))(eslint-plugin-import@2.32.0(eslint@9.37.0(jiti@2.6.1)))(eslint@9.37.0(jiti@2.6.1)):
dependencies:
'@nolyfill/is-core-module': 1.0.39
debug: 4.4.0
eslint: 9.37.0(jiti@2.6.1)
get-tsconfig: 4.12.0
is-bun-module: 2.0.0
stable-hash: 0.0.5
tinyglobby: 0.2.15
unrs-resolver: 1.11.1
optionalDependencies:
eslint-plugin-import: 2.32.0(eslint-import-resolver-typescript@3.10.1(eslint-plugin-import-x@4.3.1(eslint@9.37.0(jiti@2.6.1))(typescript@5.9.2))(eslint-plugin-import@2.32.0(eslint@9.37.0(jiti@2.6.1)))(eslint@9.37.0(jiti@2.6.1)))(eslint@9.37.0(jiti@2.6.1))
eslint-plugin-import-x: 4.3.1(eslint@9.37.0(jiti@2.6.1))(typescript@5.9.2)
transitivePeerDependencies:
- supports-color
eslint-import-resolver-typescript@3.10.1(eslint-plugin-import-x@4.3.1(eslint@9.37.0(jiti@2.6.1))(typescript@5.9.2))(eslint-plugin-import@2.32.0)(eslint@9.37.0(jiti@2.6.1)): eslint-import-resolver-typescript@3.10.1(eslint-plugin-import-x@4.3.1(eslint@9.37.0(jiti@2.6.1))(typescript@5.9.2))(eslint-plugin-import@2.32.0)(eslint@9.37.0(jiti@2.6.1)):
dependencies: dependencies:
'@nolyfill/is-core-module': 1.0.39 '@nolyfill/is-core-module': 1.0.39
...@@ -28579,6 +28603,16 @@ snapshots: ...@@ -28579,6 +28603,16 @@ snapshots:
transitivePeerDependencies: transitivePeerDependencies:
- supports-color - supports-color
eslint-module-utils@2.12.1(eslint-import-resolver-node@0.3.9)(eslint-import-resolver-typescript@3.10.1(eslint-plugin-import-x@4.3.1(eslint@9.37.0(jiti@2.6.1))(typescript@5.9.2))(eslint-plugin-import@2.32.0(eslint@9.37.0(jiti@2.6.1)))(eslint@9.37.0(jiti@2.6.1)))(eslint@9.37.0(jiti@2.6.1)):
dependencies:
debug: 3.2.7
optionalDependencies:
eslint: 9.37.0(jiti@2.6.1)
eslint-import-resolver-node: 0.3.9
eslint-import-resolver-typescript: 3.10.1(eslint-plugin-import-x@4.3.1(eslint@9.37.0(jiti@2.6.1))(typescript@5.9.2))(eslint-plugin-import@2.32.0(eslint@9.37.0(jiti@2.6.1)))(eslint@9.37.0(jiti@2.6.1))
transitivePeerDependencies:
- supports-color
eslint-plugin-eslint-plugin@5.2.1(eslint@9.37.0(jiti@2.6.1)): eslint-plugin-eslint-plugin@5.2.1(eslint@9.37.0(jiti@2.6.1)):
dependencies: dependencies:
eslint: 9.37.0(jiti@2.6.1) eslint: 9.37.0(jiti@2.6.1)
...@@ -28659,7 +28693,7 @@ snapshots: ...@@ -28659,7 +28693,7 @@ snapshots:
- eslint-import-resolver-webpack - eslint-import-resolver-webpack
- supports-color - supports-color
eslint-plugin-import@2.32.0(eslint-import-resolver-typescript@3.10.1)(eslint@9.37.0(jiti@2.6.1)): eslint-plugin-import@2.32.0(eslint-import-resolver-typescript@3.10.1(eslint-plugin-import-x@4.3.1(eslint@9.37.0(jiti@2.6.1))(typescript@5.9.2))(eslint-plugin-import@2.32.0(eslint@9.37.0(jiti@2.6.1)))(eslint@9.37.0(jiti@2.6.1)))(eslint@9.37.0(jiti@2.6.1)):
dependencies: dependencies:
'@rtsao/scc': 1.1.0 '@rtsao/scc': 1.1.0
array-includes: 3.1.9 array-includes: 3.1.9
...@@ -28670,7 +28704,7 @@ snapshots: ...@@ -28670,7 +28704,7 @@ snapshots:
doctrine: 2.1.0 doctrine: 2.1.0
eslint: 9.37.0(jiti@2.6.1) eslint: 9.37.0(jiti@2.6.1)
eslint-import-resolver-node: 0.3.9 eslint-import-resolver-node: 0.3.9
eslint-module-utils: 2.12.1(@typescript-eslint/parser@8.46.0(eslint@9.37.0(jiti@2.6.1))(typescript@5.9.2))(eslint-import-resolver-node@0.3.9)(eslint-import-resolver-typescript@3.10.1)(eslint@9.37.0(jiti@2.6.1)) eslint-module-utils: 2.12.1(eslint-import-resolver-node@0.3.9)(eslint-import-resolver-typescript@3.10.1(eslint-plugin-import-x@4.3.1(eslint@9.37.0(jiti@2.6.1))(typescript@5.9.2))(eslint-plugin-import@2.32.0(eslint@9.37.0(jiti@2.6.1)))(eslint@9.37.0(jiti@2.6.1)))(eslint@9.37.0(jiti@2.6.1))
hasown: 2.0.2 hasown: 2.0.2
is-core-module: 2.16.1 is-core-module: 2.16.1
is-glob: 4.0.3 is-glob: 4.0.3
...@@ -39984,6 +40018,10 @@ snapshots: ...@@ -39984,6 +40018,10 @@ snapshots:
imurmurhash: 0.1.4 imurmurhash: 0.1.4
signal-exit: 4.1.0 signal-exit: 4.1.0
write-file-atomic@7.0.1:
dependencies:
signal-exit: 4.1.0
write-json-file@3.2.0: write-json-file@3.2.0:
dependencies: dependencies:
detect-indent: 5.0.0 detect-indent: 5.0.0
import { ReactNode } from 'react'
export default function Root({ children }: { children: ReactNode }) {
return (
<html>
<body>{children}</body>
</html>
)
}
export default function Page() {
return <p>hello world</p>
}
import { rmSync } from 'node:fs'
import { join } from 'node:path'
import { getCacheDirectory } from 'next/dist/lib/helpers/get-cache-directory'
import { nextTestSetup } from 'e2e-utils'
import { parseTraceFile } from '../../../lib/parse-trace-file'
describe('rage restart trace attributes', () => {
// Use a fake upload URL so traceUploadUrl is set and detection runs.
// The URL doesn't need to be reachable — we inspect the trace file directly.
const fakeUploadUrl = 'http://localhost:19999'
const { next, isNextDev } = nextTestSetup({
files: __dirname,
skipStart: true,
startArgs: ['--experimental-upload-trace', fakeUploadUrl],
})
if (!isNextDev) {
it('should be skipped in production', () => {})
return
}
const getDevStateFilePath = () =>
join(getCacheDirectory('nextjs-nodejs'), 'dev-state.json')
beforeEach(async () => {
// Ensure each test starts from a clean stopped state with no prior session.
await next.stop('SIGTERM').catch(() => {})
rmSync(getDevStateFilePath(), { force: true })
})
const getTracePath = () => join(next.testDir, '.next/dev/trace')
const getStartDevServerSpan = () => {
const traceStructure = parseTraceFile(getTracePath())
const spans = traceStructure.eventsByName.get('start-dev-server')
expect(spans).toBeDefined()
expect(spans?.length).toBeGreaterThan(0)
// Trace file is appended across restarts; take the most recent span.
return spans?.[spans.length - 1]
}
it('should not set rage-restart on first start', async () => {
await next.start()
await next.render$('/')
await next.stop('SIGTERM')
const span = getStartDevServerSpan()
expect(span?.tags?.['rage-restart']).toBe(false)
expect(span?.tags?.['missing-next-dir']).toBe(false)
})
it('should set rage-restart when restarted within threshold', async () => {
// First session: establish a prior stop time.
await next.start()
await next.render$('/')
await next.stop('SIGTERM')
// Second session: restart immediately — should be detected as a rage restart.
await next.start()
await next.render$('/')
await next.stop('SIGTERM')
const span = getStartDevServerSpan()
expect(span?.tags?.['rage-restart']).toBe(true)
expect(span?.tags?.['missing-next-dir']).toBe(false)
})
it('should set missing-next-dir when .next is deleted before restart', async () => {
// First session: establish a prior stop time.
await next.start()
await next.render$('/')
await next.stop('SIGTERM')
// Delete .next to simulate the user clearing the build cache.
rmSync(join(next.testDir, '.next'), { recursive: true, force: true })
// Second session: restart — should detect both rage restart and missing .next.
await next.start()
await next.render$('/')
await next.stop('SIGTERM')
const span = getStartDevServerSpan()
expect(span?.tags?.['rage-restart']).toBe(true)
expect(span?.tags?.['missing-next-dir']).toBe(true)
})
})
...@@ -219,6 +219,7 @@ async function readNormalizedNFT(next, name) { ...@@ -219,6 +219,7 @@ async function readNormalizedNFT(next, name) {
"/node_modules/next/dist/compiled/tar/index.min.js", "/node_modules/next/dist/compiled/tar/index.min.js",
"/node_modules/next/dist/compiled/text-table/index.js", "/node_modules/next/dist/compiled/text-table/index.js",
"/node_modules/next/dist/compiled/watchpack/watchpack.js", "/node_modules/next/dist/compiled/watchpack/watchpack.js",
"/node_modules/next/dist/compiled/write-file-atomic/index.js",
"/node_modules/next/dist/compiled/ws/index.js", "/node_modules/next/dist/compiled/ws/index.js",
"/node_modules/next/dist/compiled/zod-validation-error/index.js", "/node_modules/next/dist/compiled/zod-validation-error/index.js",
"/node_modules/next/dist/compiled/zod/index.cjs", "/node_modules/next/dist/compiled/zod/index.cjs",
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment