MCPcopy
hub / github.com/vercel/next.js / uploadTrace

Function uploadTrace

packages/next/src/trace/upload-trace.ts:4–58  ·  view source on GitHub ↗
({
  traceUploadUrl,
  mode,
  projectDir,
  distDir,
  isTurboSession,
  sync,
}: {
  traceUploadUrl: string
  mode: 'dev' | 'build'
  projectDir: string
  distDir: string
  isTurboSession: boolean
  sync?: boolean
})

Source from the content-addressed store, hash-verified

2import { Telemetry } from '../telemetry/storage'
3
4export default function uploadTrace({
5 traceUploadUrl,
6 mode,
7 projectDir,
8 distDir,
9 isTurboSession,
10 sync,
11}: {
12 traceUploadUrl: string
13 mode: 'dev' | 'build'
14 projectDir: string
15 distDir: string
16 isTurboSession: boolean
17 sync?: boolean
18}) {
19 const { NEXT_TRACE_UPLOAD_DEBUG } = process.env
20 const telemetry = new Telemetry({ distDir })
21
22 // Note: cross-spawn is not used here as it causes
23 // a new command window to appear when we don't want it to
24 const child_process =
25 require('child_process') as typeof import('child_process')
26
27 // we use spawnSync when debugging to ensure logs are piped
28 // correctly to stdout/stderr
29 const spawn =
30 NEXT_TRACE_UPLOAD_DEBUG || sync
31 ? child_process.spawnSync
32 : child_process.spawn
33
34 spawn(
35 process.execPath,
36 [
37 require.resolve('./trace-uploader'),
38 traceUploadUrl,
39 mode,
40 projectDir,
41 distDir,
42 String(isTurboSession),
43 traceId,
44 telemetry.anonymousId,
45 telemetry.sessionId,
46 ],
47 {
48 detached: !NEXT_TRACE_UPLOAD_DEBUG,
49 windowsHide: true,
50 shell: false,
51 ...(NEXT_TRACE_UPLOAD_DEBUG
52 ? {
53 stdio: 'inherit',
54 }
55 : {}),
56 }
57 )
58}

Callers 2

handleSessionStopFunction · 0.85
startServerFunction · 0.85

Calls 4

resolveMethod · 0.65
requireFunction · 0.50
spawnFunction · 0.50
StringFunction · 0.50

Tested by

no test coverage detected