@opennextjs/aws 3.8.3 → 3.8.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -222,13 +222,18 @@ export class OpenNextNodeResponse extends Transform {
|
|
|
222
222
|
return Buffer.concat(this._chunks);
|
|
223
223
|
}
|
|
224
224
|
_internalWrite(chunk, encoding) {
|
|
225
|
-
|
|
225
|
+
// When encoding === 'buffer', chunk is already a Buffer
|
|
226
|
+
// and does not need to be converted again.
|
|
227
|
+
// @ts-expect-error TS2367 'encoding' can be 'buffer', but it's not in the
|
|
228
|
+
// official type definition
|
|
229
|
+
const buffer = encoding === "buffer" ? chunk : Buffer.from(chunk, encoding);
|
|
226
230
|
this.bodyLength += buffer.length;
|
|
227
231
|
if (this.streamCreator?.retainChunks !== false) {
|
|
228
232
|
// Avoid keeping chunks around when the `StreamCreator` supports it to save memory
|
|
229
233
|
this._chunks.push(buffer);
|
|
230
234
|
}
|
|
231
|
-
|
|
235
|
+
// No need to pass the encoding for buffers
|
|
236
|
+
this.push(buffer);
|
|
232
237
|
this.streamCreator?.onWrite?.();
|
|
233
238
|
}
|
|
234
239
|
_transform(chunk, encoding, callback) {
|
|
@@ -64,7 +64,12 @@ const handler = async (handler, converter) => async (request, env, ctx, abortSig
|
|
|
64
64
|
controller.error(error);
|
|
65
65
|
}
|
|
66
66
|
else {
|
|
67
|
-
|
|
67
|
+
try {
|
|
68
|
+
controller.close();
|
|
69
|
+
}
|
|
70
|
+
catch {
|
|
71
|
+
// Ignore "This ReadableStream is closed" error
|
|
72
|
+
}
|
|
68
73
|
}
|
|
69
74
|
callback(error);
|
|
70
75
|
},
|