Files
next.js/test/unit/preserve-process-env.test.ts
Tim NeutkensandGitHub b92cf40ee6 Enable Node streams by default (#94311)
### What?

Defaults `experimental.useNodeStreams` to `true` while keeping the
experimental config flag and explicit `false` opt-out available. Removes
redundant dedicated node-stream CI jobs because the ordinary path
exercises Node streams after this change.

Depends on the standalone test compatibility update in #94347, which
intentionally remains outside the Node streams PR stack.

### Why?

Node streams can be exercised through the standard Node.js App Router
test path once they are the default, allowing a smaller rollout before
the larger follow-up that removes the flag and obsolete plumbing.

CI exposed one necessary compatibility fix for this intermediate state:
projects with a `next.config.*` received the new default after raw
experimental-feature processing, leaving the runtime stream selector on
the web implementation while compiled app code selected Node stream
helpers.

### How?

- Set `defaultConfig.experimental.useNodeStreams` to `true`.
- Synchronize `__NEXT_USE_NODE_STREAMS` from the fully resolved config,
including cached and standalone resolved configs, so defaults and
adapter modifications are reflected at runtime.
- Preserve the current public config/schema and explicit `experimental:
{ useNodeStreams: false }` opt-out; edge bundles continue to define the
stream flag as `false`.
- Remove the dedicated node-stream test jobs and now-unused manifest;
the affected streaming assertion compatibility changes are isolated in
#94347.

### Verification

Run before extracting the prerequisite assertion changes into #94347:

- `pnpm --filter=next types`
- `pnpm --filter=next build`
- `IS_WEBPACK_TEST=1 __NEXT_EXPERIMENTAL_STRICT_ROUTE_TYPES=true pnpm
test-start-webpack
test/e2e/app-dir/ppr-root-param-fallback/ppr-root-param-fallback.test.ts`
- `IS_TURBOPACK_TEST=1 TURBOPACK_BUILD=1
__NEXT_EXPERIMENTAL_STRICT_ROUTE_TYPES=true pnpm test-start-turbo
test/e2e/app-dir/ppr-root-param-fallback/ppr-root-param-fallback.test.ts`
- `IS_WEBPACK_TEST=1 __NEXT_EXPERIMENTAL_STRICT_ROUTE_TYPES=true pnpm
test-start-webpack
test/e2e/app-dir/use-server-inserted-html/use-server-inserted-html.test.ts`
- `pnpm test-dev-webpack
test/e2e/app-dir/ppr-root-param-fallback/ppr-root-param-fallback.test.ts
test/e2e/app-dir/use-server-inserted-html/use-server-inserted-html.test.ts`
- `pnpm test-dev-turbo
test/e2e/app-dir/ppr-root-param-fallback/ppr-root-param-fallback.test.ts
test/e2e/app-dir/use-server-inserted-html/use-server-inserted-html.test.ts`
- `pnpm test-start-webpack
test/production/app-dir/use-node-streams-env-precedence/use-node-streams-env-precedence.test.ts`
- `pnpm test-start-webpack test/e2e/app-dir/app/standalone.test.ts`

<!-- NEXT_JS_LLM_PR -->
2026-06-02 21:34:22 +02:00

30 lines
683 B
TypeScript

import {
loadEnvConfig,
resetEnv,
updateInitialEnv,
} from '../../packages/next-env/'
describe('preserve process env', () => {
it('should not reassign `process.env`', () => {
const originalProcessEnv = process.env
loadEnvConfig('.')
expect(Object.is(originalProcessEnv, process.env)).toBeTrue()
})
it('should remove values unset in the initial env snapshot', () => {
const key = '__NEXT_TEST_UNSET_INITIAL_ENV'
try {
loadEnvConfig('.')
process.env[key] = 'changed'
updateInitialEnv({ [key]: undefined })
resetEnv()
expect(process.env[key]).toBeUndefined()
} finally {
delete process.env[key]
}
})
})