rsnext/packages/next/build/webpack/plugins
Jimmy Lai 589f090d0b
memory: fix 2 memory leaks in next-dev (#43859)
This PR fixes two memory leaks I found debugging with @sokra.

## 1) Leak in `next-server.ts`

The first leak was caused by the fact that the `require.cache` associated to the `next-server` module was not being cleared up properly, so we leaked context from modules required in that page, like API routes.

## 2)  Leak with React Fetch

When evaluating a route, we also evaluated the `react.shared-subset.development.js` module where React patches the `fetch` function. The problem is that when re-evaluating a route as part of hot reloading, we were patching over the previously patched `fetch` function. 
The result of this operation meant that we were keeping a reference to the context of the previous `fetch` and thus to the previous route context, thus creating a memory leak, since we only needed the new context.

## Test plan

Checked manually the heap snapshots of a test app.

## Bug

- [ ] Related issues linked using `fixes #number`
- [ ] Integration tests added
- [ ] Errors have a helpful link attached, see [`contributing.md`](https://github.com/vercel/next.js/blob/canary/contributing.md)

## Feature

- [ ] Implements an existing feature request or RFC. Make sure the feature request has been accepted for implementation before opening a PR.
- [ ] Related issues linked using `fixes #number`
- [ ] [e2e](https://github.com/vercel/next.js/blob/canary/contributing/core/testing.md#writing-tests-for-nextjs) tests added
- [ ] Documentation added
- [ ] Telemetry added. In case of a feature if it's used or not.
- [ ] Errors have a helpful link attached, see [`contributing.md`](https://github.com/vercel/next.js/blob/canary/contributing.md)

## Documentation / Examples

- [ ] Make sure the linting passes by running `pnpm build && pnpm lint`
- [ ] The "examples guidelines" are followed from [our contributing doc](https://github.com/vercel/next.js/blob/canary/contributing/examples/adding-examples.md)
2022-12-08 19:50:46 +00:00
..
terser-webpack-plugin Set swcMinify as an attribute on terser-webpack-plugin-optimize span (#37416) 2022-06-06 15:09:33 +00:00
wellknown-errors-plugin Assign layer to app client entries (#43197) 2022-12-07 15:20:50 +01:00
app-build-manifest-plugin.ts types: leverage webpack types and remove casting (#42104) 2022-10-29 04:00:33 +02:00
build-manifest-plugin.ts chore: remove unsless @ts-ignore (#40992) 2022-09-28 17:53:08 +00:00
copy-file-plugin.ts chore: remove unsless @ts-ignore (#40992) 2022-09-28 17:53:08 +00:00
css-minimizer-plugin.ts chore: remove unsless @ts-ignore (#40992) 2022-09-28 17:53:08 +00:00
flight-client-entry-plugin.ts Remove resolved app directory todos (#43672) 2022-12-03 20:34:53 +00:00
flight-manifest-plugin.ts Get correct chunks in flight-manifest on Windows (#43334) 2022-11-25 08:36:26 +00:00
flight-types-plugin.ts fix(ts): re-export PageComponent and LayoutComponent types (#43226) 2022-11-22 13:49:01 +01:00
font-loader-manifest-plugin.ts Recover from font loader error in dev (#41251) 2022-10-08 01:53:24 +02:00
font-stylesheet-gathering-plugin.ts BREAKING CHANGE: Remove target: serverless (#41495) 2022-10-18 09:47:13 -07:00
jsconfig-paths-plugin.ts Add handling for auto installing TypeScript deps and HMRing tsconfig (#39838) 2022-08-23 13:16:47 -05:00
middleware-plugin.ts Fix matchers in middleware manifest (#43549) 2022-11-29 23:55:13 +00:00
mini-css-extract-plugin.ts use official mini-css-extract-plugin and experimentalUseImportModule (#24573) 2021-05-12 16:04:01 +00:00
next-drop-client-page-plugin.ts chore: remove unsless @ts-ignore (#40992) 2022-09-28 17:53:08 +00:00
next-trace-entrypoints-plugin.ts Imageloader: collect images serverside to include images from staticp… (#41554) 2022-11-23 09:28:53 -05:00
nextjs-require-cache-hot-reloader.ts memory: fix 2 memory leaks in next-dev (#43859) 2022-12-08 19:50:46 +00:00
pages-manifest-plugin.ts BREAKING CHANGE: Remove target: serverless (#41495) 2022-10-18 09:47:13 -07:00
profiling-plugin.ts Remove webpack4 types (#39631) 2022-08-16 09:55:37 +00:00
react-loadable-plugin.ts chore: remove unsless @ts-ignore (#40992) 2022-09-28 17:53:08 +00:00
subresource-integrity-plugin.ts Make sure polyfills are added for browsers without module support (#41029) 2022-09-29 16:22:21 -07:00
telemetry-plugin.ts Add telemetry for @next/font (#42579) 2022-11-08 09:02:26 -08:00