Skip to content

Commit

Permalink
test(integration): properly pipe turbopack binary stdouts (#46382)
Browse files Browse the repository at this point in the history
<!--
Thanks for opening a PR! Your contribution is much appreciated.
To make sure your PR is handled as smoothly as possible we request that
you follow the checklist sections below.
Choose the right checklist for the change(s) that you're making:
-->

Partially resolves WEB-628

Starting next-dev relies on some stdout status to grab its devserver
url, and this PR correctly bubbles up custom turbopack binary's stdout
to make it work.
  • Loading branch information
kwonoj committed Feb 25, 2023
1 parent 725a4de commit ccdb869
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 5 deletions.
12 changes: 8 additions & 4 deletions packages/next/src/build/swc/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -424,13 +424,17 @@ function loadNative(isCustomTurbopack = false) {

let child = spawn(__INTERNAL_CUSTOM_TURBOPACK_BINARY, args, {
stdio: 'pipe',
env: {
...process.env,
},
})
child.on('message', (message: any) => {
console.log(message)
require('console').log(message)
})
child.stdout.on('data', (data: any) => {
require('console').log(data.toString())
})
child.stderr.on('data', (data: any) => {
require('console').log(data.toString())
})

child.on('close', (code: any) => {
if (code !== 0) {
reject({
Expand Down
4 changes: 3 additions & 1 deletion packages/next/src/cli/next-dev.ts
Original file line number Diff line number Diff line change
Expand Up @@ -461,7 +461,9 @@ If you cannot make the changes above, but still want to try out\nNext.js v13 wit
// Start preflight after server is listening and ignore errors:
preflight().catch(() => {})

await telemetry.flush()
if (!isCustomTurbopack) {
await telemetry.flush()
}
return server
} else {
// we're using a sub worker to avoid memory leaks. When memory usage exceeds 90%, we kill the worker and restart it.
Expand Down

0 comments on commit ccdb869

Please sign in to comment.