Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in
Toggle navigation
N
next.js
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Alex
next.js
Commits
069b8f47
Commit
069b8f47
authored
Jan 30, 2025
by
Tobias Koppers
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
await shutdown before ending pool
parent
6c632b81
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
14 additions
and
3 deletions
+14
-3
impl.ts
packages/next/src/build/turbopack-build/impl.ts
+8
-0
index.ts
packages/next/src/build/turbopack-build/index.ts
+6
-3
No files found.
packages/next/src/build/turbopack-build/impl.ts
View file @
069b8f47
...
...
@@ -306,6 +306,7 @@ export async function turbopackBuild(): Promise<{
}
}
let
shutdownPromise
:
Promise
<
void
>
|
undefined
export
async
function
workerMain
(
workerData
:
{
buildContext
:
typeof
NextBuildContext
}):
Promise
<
Awaited
<
ReturnType
<
typeof
turbopackBuild
>>>
{
...
...
@@ -332,5 +333,12 @@ export async function workerMain(workerData: {
setGlobal
(
'telemetry'
,
telemetry
)
const
result
=
await
turbopackBuild
()
shutdownPromise
=
result
.
shutdownPromise
return
result
}
export
async
function
waitForShutdown
():
Promise
<
void
>
{
if
(
shutdownPromise
)
{
await
shutdownPromise
}
}
packages/next/src/build/turbopack-build/index.ts
View file @
069b8f47
...
...
@@ -11,7 +11,7 @@ async function turbopackBuildWithWorker() {
try
{
const
worker
=
new
Worker
(
path
.
join
(
__dirname
,
'impl.js'
),
{
exposedMethods
:
[
'workerMain'
],
exposedMethods
:
[
'workerMain'
,
'waitForShutdown'
],
numWorkers
:
1
,
maxRetries
:
0
,
forkOptions
:
{
...
...
@@ -27,8 +27,11 @@ async function turbopackBuildWithWorker() {
buildContext
:
prunedBuildContext
,
})
// destroy worker so it's not sticking around using memory
await
worker
.
end
()
// destroy worker when Turbopack has shutdown so it's not sticking around using memory
// We need to wait for shutdown to make sure persistent cache is flushed
result
.
shutdownPromise
=
worker
.
waitForShutdown
().
then
(()
=>
{
worker
.
end
()
})
return
result
}
catch
(
err
:
any
)
{
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment