Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Trace upload fixup #54455

Merged
merged 4 commits into from
Aug 24, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
20 changes: 13 additions & 7 deletions packages/next/src/cli/next-dev.ts
Original file line number Diff line number Diff line change
Expand Up @@ -90,13 +90,19 @@ const handleSessionStop = async () => {
}

if (traceUploadUrl) {
uploadTrace({
traceUploadUrl,
mode: 'dev',
isTurboSession,
projectDir: dir,
distDir: config.distDir,
})
if (isTurboSession) {
console.warn(
'Uploading traces with Turbopack is not yet supported. Skipping sending trace.'
)
} else {
uploadTrace({
traceUploadUrl,
mode: 'dev',
isTurboSession,
projectDir: dir,
distDir: config.distDir,
})
}
}

// ensure we re-enable the terminal cursor before exiting
Expand Down
4 changes: 3 additions & 1 deletion packages/next/src/server/dev/hot-reloader.ts
Original file line number Diff line number Diff line change
Expand Up @@ -397,7 +397,9 @@ export default class HotReloader {
endTime:
BigInt(payload.endTime) * BigInt(MILLISECONDS_IN_NANOSECOND),
attrs: {
updatedModules: payload.updatedModules,
updatedModules: payload.updatedModules.map((m: string) =>
m.replace(/^\.\//, '[project]/')
),
page: payload.page,
},
}
Expand Down
16 changes: 13 additions & 3 deletions packages/next/src/trace/trace-uploader.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ const EVENT_FILTER = new Set([
'hot-reloader',
'webpack-invalid-client',
'webpack-invalidated-server',
'navigation-to-hydration',
])

const {
Expand Down Expand Up @@ -58,9 +59,17 @@ interface TraceMetadata {
pkgName: string
platform: string
isTurboSession: boolean
nextVersion: string
}

;(async function upload() {
const nextVersion = JSON.parse(
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

curious if this'll work if next.js is installed as dep in normal project?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, tested this and it works.

await fsPromise.readFile(
path.resolve(__dirname, '../../package.json'),
'utf8'
)
).version

const projectPkgJsonPath = await findUp('package.json')
assert(projectPkgJsonPath)

Expand Down Expand Up @@ -116,12 +125,13 @@ interface TraceMetadata {

const body: TraceRequestBody = {
metadata: {
arch: os.arch(),
commit,
cpus: os.cpus().length,
isTurboSession,
mode,
nextVersion,
pkgName,
isTurboSession,
arch: os.arch(),
cpus: os.cpus().length,
platform: os.platform(),
},
traces: [...traces.values()],
Expand Down