MCPcopy
hub / github.com/vercel/next.js / cleanup

Function cleanup

packages/next/src/server/lib/router-utils/proxy-request.ts:60–70  ·  view source on GitHub ↗
(err: any)

Source from the content-addressed store, hash-verified

58
59 proxy.on('proxyRes', (proxyRes, innerReq, innerRes) => {
60 const cleanup = (err: any) => {
61 // cleanup event listeners to allow clean garbage collection
62 proxyRes.removeListener('error', cleanup)
63 proxyRes.removeListener('close', cleanup)
64 innerRes.removeListener('error', cleanup)
65 innerRes.removeListener('close', cleanup)
66
67 // destroy all source streams to propagate the caught event backward
68 innerReq.destroy(err)
69 proxyRes.destroy(err)
70 }
71
72 proxyRes.once('error', cleanup)
73 proxyRes.once('close', cleanup)

Callers

nothing calls this directly

Calls 2

removeListenerMethod · 0.45
destroyMethod · 0.45

Tested by

no test coverage detected