Unverified Commit 4228478b authored by Josh Story's avatar Josh Story Committed by GitHub

Fix node:stream leak in webpack edge bundles (#94585)

parent adb29136
...@@ -155,10 +155,12 @@ export class ReplayableNodeStream { ...@@ -155,10 +155,12 @@ export class ReplayableNodeStream {
} }
let ReadableCtor: typeof import('node:stream').Readable let ReadableCtor: typeof import('node:stream').Readable
if (process.env.TURBOPACK) { if (process.env.NEXT_RUNTIME === 'edge') {
ReadableCtor = (require('node:stream') as typeof import('node:stream')) throw new InvariantError(
.Readable 'Node.js Readable cannot be teed in the edge runtime'
} else if (process.env.__NEXT_BUNDLER === 'Webpack') { )
} else {
if (process.env.__NEXT_BUNDLER === 'Webpack') {
ReadableCtor = ( ReadableCtor = (
__non_webpack_require__('node:stream') as typeof import('node:stream') __non_webpack_require__('node:stream') as typeof import('node:stream')
).Readable ).Readable
...@@ -166,6 +168,7 @@ export class ReplayableNodeStream { ...@@ -166,6 +168,7 @@ export class ReplayableNodeStream {
ReadableCtor = (require('node:stream') as typeof import('node:stream')) ReadableCtor = (require('node:stream') as typeof import('node:stream'))
.Readable .Readable
} }
}
const bufferedChunks = this._chunks.slice() const bufferedChunks = this._chunks.slice()
let bufferIndex = 0 let bufferIndex = 0
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment