rsnext/test/e2e
Tim Neutkens c5a8e0989e
Consolidate Server and Routing process into one process (#53523)
In the current version of Next.js there are 4 processes when running in
production:

- Server
- Routing
- Rendering Pages Router
- Rendering App Router

This setup was introduced in order to allow App Router and Pages Router
to use different versions of React (i.e. Server Actions currently
requires react@experimental to function). I wrote down more on why these
processes exist in this comment:
https://github.com/vercel/next.js/issues/49929#issuecomment-1637185156

This PR combines the Server and Routing process into one handler, as the
"Server" process was only proxying to the Routing process. In my testing
this caused about ~2x the amount of memory per request as the response
body was duplicated between the processes. This was especially visible
in the case of that memory leak in Node.js 18.16 as it grew memory usage
on both sides quickly.

In the process of going through these changes I found a couple of other
bugs like the propagation of values to the worker processes not being
awaited
([link](https://github.com/vercel/next.js/pull/53523/files#diff-0ef09f360141930bb03263b378d37d71ad9432ac851679aeabc577923536df84R54))
and the dot syntax for propagation was not functioning.

It also seemed there were a few cases where watchpack was used that
would cause many more files to be watched than expected, for now I've
removed those cases, specifically the "delete dir while running" and
instrument.js hmr (instrument.js is experimental). Those tests have been
skipped for now until we can revisit them to verfiy it

I've also cleaned up the types a bit while I was looking into these
changes.

### Improvement

⚠️ Important preface to this, measuring memory usage / peak usage is not
super reliable especially when JS gets garbage collected. These numbers
are just to show the rough percentage of less memory usage.

#### Baseline

Old:

```
next-server: 44.8MB
next-router-worker: 57.5MB
next-render-worker-app: 39,6MB
next-render-worker-pages: 39,1MB
```

New:

```
next-server: Removed
next-router-worker: 64.4MB
next-render-worker-app: 43.1MB (Note: no changes here, this shows what I meant by rough numbers)
next-render-worker-pages: 42.4MB (Note: no changes here, this shows what I meant by rough numbers)
```

Overall win: ~40MB (process is removed)

#### Peak usage

Old:

```
next-server: 118.6MB
next-router-worker: 223.7MB
next-render-worker-app: 32.8MB (I ran the test on a pages application in this case)
next-render-worker-pages: 101.1MB
```

New:

```
next-server: Removed
next-router-worker: 179.1MB
next-render-worker-app: 33.4MB
next-render-worker-pages: 117.5MB
```

Overall win: ~100MB (but it scales with requests so it was about ~50% of
next-router-worker constantly)

Related: #53523

---------

Co-authored-by: JJ Kasper <jj@jjsweb.site>
2023-08-08 16:06:32 +02:00
..
404-page-router Add new build and test workflow (#50436) 2023-05-27 21:02:31 -07:00
app-dir Add docs page for uncaught DynamicServerErrors (#53402) 2023-08-08 12:49:53 +02:00
app-dir-legacy-edge-runtime-config Update links from beta to stable docs. (#49349) 2023-05-11 11:52:29 -07:00
basepath Add initial separated route resolving (#47208) 2023-04-02 15:17:15 +02:00
browserslist BREAKING CHANGE: Remove browsersListForSwc and change default to legacyBrowsers: false (#41529) 2022-10-19 01:38:39 +00:00
browserslist-extends Ensure browserslist extends works properly (#33890) 2022-02-02 13:23:51 -06:00
cancel-request Try to fix flakey socket hang up failures in stream cancel tests (#53318) 2023-07-28 22:59:24 +00:00
config-promise-export Add support for async fn / promise in next.config.js/.mjs (#33662) 2022-02-07 08:48:35 +00:00
conflicting-app-page-error Hot reload when conflicted pages detected and when conflicts are resolved (#51516) 2023-06-22 22:32:14 +00:00
custom-app-render Revert "Revert "Separate routing code from render servers (#52492)"" (#53029) 2023-07-21 14:02:52 -07:00
disable-js-preload Enable App Router for all applications (#49088) 2023-05-04 17:47:10 +02:00
dynamic-route-interpolation BREAKING CHANGE: Enable newNextLinkBehavior (#41459) 2022-10-17 21:20:28 -04:00
edge-api-endpoints-can-receive-body feat: enables 'edge' as a possible runtime for API routes (#44045) 2022-12-15 10:08:03 +01:00
edge-async-local-storage feat: enables 'edge' as a possible runtime for API routes (#44045) 2022-12-15 10:08:03 +01:00
edge-can-read-request-body type check tests (and convert next-test-utils.js to ts) (#51071) 2023-06-23 17:42:50 +00:00
edge-can-use-wasm-files feat: enables 'edge' as a possible runtime for API routes (#44045) 2022-12-15 10:08:03 +01:00
edge-compiler-can-import-blob-assets Add client router filter handling (#46283) 2023-02-22 22:02:31 -08:00
edge-compiler-module-exports-preference Update some flaking tests for edge compiler and rsc (#38344) 2022-07-05 14:37:42 -05:00
edge-configurable-runtime Remove edge functions tracking in dev server (#51122) 2023-06-14 13:17:16 +02:00
edge-pages-support Enable Pages Route Module Rendering for Edge (#51894) 2023-06-30 18:42:58 +00:00
edge-runtime-uses-edge-light-import-specifier-for-packages Remove experimental config from create-next-app (#49241) 2023-05-05 00:22:28 -07:00
fetch-failures-have-good-stack-traces-in-edge-runtime Fix fetch stack test on deploy 2023-01-27 18:23:27 -08:00
getserversideprops Update query param prefix to reduce length (#48051) 2023-04-06 17:52:24 -07:00
handle-non-hoisted-swc-helpers Update swc_core to v0.75.23 (#48098) 2023-04-18 08:59:52 +02:00
hello-world Bail out of 404 page when favicon.ico doesn't exist (#50795) 2023-06-06 10:58:40 +02:00
i18n-api-support Enable E2E deploy tests on publish (#37019) 2022-05-21 04:46:16 -05:00
i18n-data-fetching-redirect BREAKING CHANGE: Enable newNextLinkBehavior (#41459) 2022-10-17 21:20:28 -04:00
i18n-default-locale-redirect Handle defaultLocale on client router filter (#47180) 2023-03-16 11:58:02 -07:00
i18n-disallow-multiple-locales Update failing i18n e2e deploy test (#47462) 2023-03-23 15:53:14 -07:00
i18n-ignore-redirect-source-locale i18n regression tests and docs for ignore locale in rewrite (#37581) 2022-06-10 14:04:31 -05:00
i18n-ignore-rewrite-source-locale i18n regression tests and docs for ignore locale in rewrite (#37581) 2022-06-10 14:04:31 -05:00
ignore-invalid-popstateevent Move core files to src folder and move JS files to TypeScript (#44405) 2023-01-03 10:05:50 +01:00
instrumentation-hook Consolidate Server and Routing process into one process (#53523) 2023-08-08 16:06:32 +02:00
instrumentation-hook-src Consolidate Server and Routing process into one process (#53523) 2023-08-08 16:06:32 +02:00
link-with-api-rewrite BREAKING CHANGE: Enable newNextLinkBehavior (#41459) 2022-10-17 21:20:28 -04:00
manual-client-base-path Update manual basePath with trailingSlash (#51726) 2023-06-23 15:36:16 -07:00
middleware-base-path BREAKING CHANGE: Enable newNextLinkBehavior (#41459) 2022-10-17 21:20:28 -04:00
middleware-custom-matchers Add initial separated route resolving (#47208) 2023-04-02 15:17:15 +02:00
middleware-custom-matchers-basepath Add initial separated route resolving (#47208) 2023-04-02 15:17:15 +02:00
middleware-custom-matchers-i18n Add initial separated route resolving (#47208) 2023-04-02 15:17:15 +02:00
middleware-dynamic-basepath-matcher chore: fix flaky middleware matcher test (#49555) 2023-05-09 22:37:03 +00:00
middleware-fetches-with-any-http-method [middleware] Support any method when fetching a Request instance (#37540) 2022-06-08 11:00:49 +00:00
middleware-fetches-with-body Revert "Revert "Separate routing code from render servers (#52492)"" (#53029) 2023-07-21 14:02:52 -07:00
middleware-general Revert "Revert "Separate routing code from render servers (#52492)"" (#53029) 2023-07-21 14:02:52 -07:00
middleware-matcher BREAKING CHANGE: Enable newNextLinkBehavior (#41459) 2022-10-17 21:20:28 -04:00
middleware-redirects Update client router filter to separate redirects handling (#46752) 2023-03-03 16:02:02 -08:00
middleware-request-header-overrides type check tests (and convert next-test-utils.js to ts) (#51071) 2023-06-23 17:42:50 +00:00
middleware-responses Enable allowMiddlewareResponseBody by default (#44224) 2022-12-21 18:40:58 +00:00
middleware-rewrites Fix external rewrite with body (#49487) 2023-05-08 15:22:02 -07:00
middleware-shallow-link Update test env variable passing (#44912) 2023-01-15 23:20:16 -08:00
middleware-trailing-slash Allow next/headers in middleware & draftMode in edge runtime (#53465) 2023-08-02 20:22:35 +00:00
multi-zone Update default moduleResolution in tsconfig.json from node to bundler (#51957) 2023-07-18 15:11:09 +00:00
new-link-behavior Update default moduleResolution in tsconfig.json from node to bundler (#51957) 2023-07-18 15:11:09 +00:00
next-font type check tests (and convert next-test-utils.js to ts) (#51071) 2023-06-23 17:42:50 +00:00
next-head Add strict next head handling (#47938) 2023-04-05 08:29:36 +00:00
next-image-forward-ref Add ref forwarding for next/image (#43193) 2022-11-25 15:08:50 +00:00
next-script test(next-script): teardown next-dev instance via jest hooks (#46383) 2023-02-24 13:28:05 -08:00
no-eslint-warn-with-no-eslint-config fix: detect ESLint config in package.json (#40158) 2022-09-01 16:23:03 +00:00
nonce-head-manager
og-api Remove experimental config from create-next-app (#49241) 2023-05-05 00:22:28 -07:00
opentelemetry Revert "Revert "Separate routing code from render servers (#52492)"" (#53029) 2023-07-21 14:02:52 -07:00
optimized-loading Enable App Router for all applications (#49088) 2023-05-04 17:47:10 +02:00
postcss-config-cjs Fix postcss deploy e2e test (#38782) 2022-07-18 20:21:35 -05:00
prerender chore: show large data warning once per page on prod (#46323) 2023-02-25 12:29:59 -08:00
prerender-native-module
proxy-request-with-middleware Add initial separated route resolving (#47208) 2023-04-02 15:17:15 +02:00
reload-scroll-backforward-restoration BREAKING CHANGE: Enable newNextLinkBehavior (#41459) 2022-10-17 21:20:28 -04:00
repeated-forward-slashes-error Add page path to repeated slashes in href error (#46557) 2023-03-01 00:10:11 -08:00
skip-trailing-slash-redirect Fix skipMiddlewareUrlNormalize with i18n (#47773) 2023-03-31 18:24:20 -07:00
ssr-react-context fix: react dev bundle is picked in prod mode (#39221) 2022-08-01 14:21:42 +00:00
streaming-ssr Enable App Router for all applications (#49088) 2023-05-04 17:47:10 +02:00
styled-jsx Revert "Merge e2e test node_modules (#40926)" (#40974) 2022-09-28 08:08:46 +00:00
swc-warnings Add experimental flag to force SWC transforms (#36789) 2022-05-10 10:33:31 +00:00
switchable-runtime Allow next/headers in middleware & draftMode in edge runtime (#53465) 2023-08-02 20:22:35 +00:00
test-template/{{ toFileName name }} Change test template to use TS and improve template for app-dir (#44227) 2023-01-06 20:36:47 +00:00
test-utils-tests/basic Cache package lock when running tests to speed up installation (#44520) 2023-01-03 11:55:28 +01:00
third-parties Adding GoogleMaps and Youtube embed components (#52909) 2023-08-07 19:38:13 +00:00
trailingslash-with-rewrite fix: properly handle trailingSlash: true and rewrites (#43641) 2022-12-02 22:04:36 -08:00
transpile-packages Move transpilePackages out of experimental (#44194) 2022-12-20 17:27:30 +00:00
type-module-interop Update test env variable passing (#44912) 2023-01-15 23:20:16 -08:00
typescript-version-no-warning Bump to typescript@5.1 (#50557) 2023-06-08 17:18:37 +00:00
typescript-version-warning Bump to typescript@5.1 (#50557) 2023-06-08 17:18:37 +00:00
undici-fetch feat: make enableUndici: true default and remove node-fetch (#49061) 2023-05-02 04:10:59 +00:00
yarn-pnp/test Revert "Implement new forking technique for vendored packages. (#51083)" (#53640) 2023-08-06 13:00:12 -07:00
basepath-trailing-slash.test.ts
basepath.test.ts Update some flakey test cases (#43247) 2022-11-22 09:50:03 -08:00
example-file.txt Update pnpm new-test to use createNextDescribe (#44147) 2022-12-19 20:08:50 +01:00
example.txt Fix test template example (#44170) 2022-12-19 16:31:28 -08:00
prerender-crawler.test.ts
prerender-native-module.test.ts
prerender.test.ts type check tests (and convert next-test-utils.js to ts) (#51071) 2023-06-23 17:42:50 +00:00