diff --git a/packages/next/src/server/app-render/debug-channel-server.web.ts b/packages/next/src/server/app-render/debug-channel-server.web.ts
index c30480d7a337..c84c581e2248 100644
--- a/packages/next/src/server/app-render/debug-channel-server.web.ts
+++ b/packages/next/src/server/app-render/debug-channel-server.web.ts
@@ -54,5 +54,5 @@ export function createWebDebugChannel(): DebugChannelPair {
* which expects debugChannel to be a Node.js stream with a .write() method.
*/
export function createNodeDebugChannel(): DebugChannelPair {
- throw new Error('not implemented')
+ throw new Error('Not implemented')
}
diff --git a/packages/next/src/server/app-render/stream-ops.node.ts b/packages/next/src/server/app-render/stream-ops.node.ts
index 554246405494..8d5c119096fe 100644
--- a/packages/next/src/server/app-render/stream-ops.node.ts
+++ b/packages/next/src/server/app-render/stream-ops.node.ts
@@ -26,7 +26,6 @@ import {
streamToString as webStreamToString,
createDocumentClosingStream as webCreateDocumentClosingStream,
createRuntimePrefetchTransformStream,
- CLOSE_TAG,
} from '../stream-utils/node-web-streams-helper'
import { indexOfUint8Array } from '../stream-utils/uint8array-helpers'
import { ENCODED_TAGS } from '../stream-utils/encoded-tags'
@@ -210,9 +209,7 @@ function createFlightDataInjectionTransform(
const nodeTransform = new Transform({
transform(chunk, _encoding, callback) {
this.push(chunk)
- if (delayDataUntilFirstHtmlChunk) {
- startOrContinuePulling(this)
- }
+ startOrContinuePulling(this)
callback()
},
flush(callback) {
@@ -263,7 +260,7 @@ function createHeadInsertionTransform(
if (index !== -1) {
if (insertion) {
const encodedInsertion = Buffer.from(insertion)
- const merged = Buffer.allocUnsafe(
+ const merged = Buffer.alloc(
chunk.length + encodedInsertion.length
)
merged.set(chunk.slice(0, index))
@@ -336,6 +333,8 @@ function createMetadataTransform(
}
iconMarkLength = ENCODED_TAGS.META.ICON_MARK.length
+ // 47 is `/` – handle self-closing `` (length +2 for `/>`)
+ // vs non-self-closing `` (length +1 for `>`)
if (chunk[iconMarkIndex + iconMarkLength] === 47) {
iconMarkLength += 2
} else {
@@ -345,7 +344,7 @@ function createMetadataTransform(
if (chunkIndex === 0) {
closedHeadIndex = indexOfUint8Array(chunk, ENCODED_TAGS.CLOSED.HEAD)
if (iconMarkIndex < closedHeadIndex) {
- const replaced = Buffer.allocUnsafe(chunk.length - iconMarkLength)
+ const replaced = Buffer.alloc(chunk.length - iconMarkLength)
replaced.set(chunk.subarray(0, iconMarkIndex))
replaced.set(
chunk.subarray(iconMarkIndex + iconMarkLength),
@@ -356,7 +355,7 @@ function createMetadataTransform(
const insertion = await insert()
const encodedInsertion = Buffer.from(insertion)
const insertionLength = encodedInsertion.length
- const replaced = Buffer.allocUnsafe(
+ const replaced = Buffer.alloc(
chunk.length - iconMarkLength + insertionLength
)
replaced.set(chunk.subarray(0, iconMarkIndex))
@@ -372,7 +371,7 @@ function createMetadataTransform(
const insertion = await insert()
const encodedInsertion = Buffer.from(insertion)
const insertionLength = encodedInsertion.length
- const replaced = Buffer.allocUnsafe(
+ const replaced = Buffer.alloc(
chunk.length - iconMarkLength + insertionLength
)
replaced.set(chunk.subarray(0, iconMarkIndex))
@@ -393,36 +392,6 @@ function createMetadataTransform(
})
}
-// ---------------------------------------------------------------------------
-// Deferred suffix – Node.js Transform that appends a suffix string after the
-// first HTML chunk, deferring via queueMicrotask so the chunk flushes first.
-// ---------------------------------------------------------------------------
-
-function createDeferredSuffixTransform(suffix: string): Transform {
- let flushed = false
- const encodedSuffix = Buffer.from(suffix)
-
- return new Transform({
- transform(chunk, _encoding, callback) {
- this.push(chunk)
-
- if (!flushed) {
- flushed = true
- queueMicrotask(() => {
- this.push(encodedSuffix)
- })
- }
- callback()
- },
- flush(callback) {
- if (!flushed) {
- this.push(encodedSuffix)
- }
- callback()
- },
- })
-}
-
// ---------------------------------------------------------------------------
// Move suffix – Node.js Transform that strips