@@ -3,6 +3,7 @@ import { createRequire } from 'module'
33import { basename , extname , join , relative , isAbsolute , resolve } from 'path'
44import { pathToFileURL } from 'url'
55import findUp from 'next/dist/compiled/find-up'
6+ import semver from 'next/dist/compiled/semver'
67import * as Log from '../build/output/log'
78import * as ciEnvironment from '../server/ci-info'
89import {
@@ -1690,6 +1691,49 @@ function assignDefaultsAndValidate(
16901691 result . experimental . useCache = result . cacheComponents
16911692 }
16921693
1694+ const pluginRuntimeStrategy =
1695+ result . experimental . turbopackPluginRuntimeStrategy
1696+ if (
1697+ pluginRuntimeStrategy === 'workerThreads' ||
1698+ pluginRuntimeStrategy === 'forceWorkerThreads'
1699+ ) {
1700+ result . experimental . turbopackPluginRuntimeStrategy = 'workerThreads'
1701+
1702+ if ( ! process . versions . bun && ! process . versions . deno ) {
1703+ const nodeVersion = process . versions . node
1704+ const affectedNodeRange = '>=24.13.1'
1705+ if (
1706+ semver . satisfies ( nodeVersion , affectedNodeRange , {
1707+ includePrerelease : true ,
1708+ } )
1709+ ) {
1710+ if ( pluginRuntimeStrategy === 'forceWorkerThreads' ) {
1711+ Log . warn (
1712+ `\`experimental.turbopackPluginRuntimeStrategy = ` +
1713+ `'forceWorkerThreads'\` is enabled, bypassing protection ` +
1714+ `against a known potential crash in Node.js ${ affectedNodeRange } .\n` +
1715+ `A Node.js worker-thread teardown bug can abort the process ` +
1716+ `when a native addon, such as fsevents, has a live Node-API ` +
1717+ `threadsafe function as a worker exits.\n` +
1718+ `See https://github.com/nodejs/node/issues/65100.`
1719+ )
1720+ } else {
1721+ Log . warn (
1722+ `\`experimental.turbopackPluginRuntimeStrategy = ` +
1723+ `'workerThreads'\` is disabled on Node.js ${ nodeVersion } .\n` +
1724+ `A Node.js worker-thread teardown bug can abort the process ` +
1725+ `when a native addon, such as fsevents, has a live Node-API ` +
1726+ `threadsafe function as a worker exits.\n` +
1727+ `See https://github.com/nodejs/node/issues/65100.\n` +
1728+ `Falling back to 'childProcesses'. To override at your own ` +
1729+ `risk, use 'forceWorkerThreads'.`
1730+ )
1731+ result . experimental . turbopackPluginRuntimeStrategy = 'childProcesses'
1732+ }
1733+ }
1734+ }
1735+ }
1736+
16931737 // Store the distDirRoot in the config before it is modified for development mode
16941738 ; ( result as NextConfigComplete ) . distDirRoot = result . distDir
16951739
0 commit comments