Skip to content

Commit 6f0295e

Browse files
committed
fix: import Transform from node:stream to fix ReferenceError on unencoded requests
Fixes #1063 The compression support switch (commit 1a7f4a9) references in the default case, but is never imported. Every request without a Content-Encoding header throws . Changes: - Add - Use instead of
1 parent 178784c commit 6f0295e

1 file changed

Lines changed: 6 additions & 12 deletions

File tree

src/Formidable.js

Lines changed: 6 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ import fsPromises from 'node:fs/promises';
88
import os from 'node:os';
99
import path from 'node:path';
1010
import { StringDecoder } from 'node:string_decoder';
11+
import { Transform } from 'node:stream';
1112
import once from 'once';
1213
import FormidableError, * as errors from './FormidableError.js';
1314
import PersistentFile from './PersistentFile.js';
@@ -273,13 +274,12 @@ class IncomingForm extends EventEmitter {
273274
pipe = require("zlib").createUnzip();
274275
break;
275276

276-
default:
277-
pipe = node_stream.Transform({
278-
transform: function (chunk, encoding, callback) {
277+
default:
278+
pipe = new Transform({
279+
transform(chunk, encoding, callback) {
279280
callback(null, chunk);
280-
}
281-
282-
})
281+
},
282+
});
283283
}
284284
pipe.on("data", datafn).on('end', endfn);
285285
req.pipe(pipe)
@@ -403,12 +403,6 @@ class IncomingForm extends EventEmitter {
403403
});
404404
this.emit('fileBegin', part.name, file);
405405

406-
// Check for error after fileBegin (e.g., maxFiles exceeded) to avoid leaking file handles
407-
if (this.error) {
408-
this._flushing -= 1;
409-
return;
410-
}
411-
412406
file.open();
413407
this.openedFiles.push(file);
414408

0 commit comments

Comments
 (0)