[Fizz] Always call flush() if it exists (#21625)

This commit is contained in:
Dan Abramov 2021-06-04 20:17:57 +01:00 committed by GitHub
parent 46926993fc
commit cc4d24ab0b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 3 additions and 8 deletions

View File

@ -11,8 +11,6 @@ import type {Writable} from 'stream';
type MightBeFlushable = {
flush?: () => void,
// Legacy
flushHeaders?: () => void,
...
};
@ -31,12 +29,9 @@ export function flushBuffered(destination: Destination) {
// If we don't have any more data to send right now.
// Flush whatever is in the buffer to the wire.
if (typeof destination.flush === 'function') {
// http.createServer response have flush(), but it has a different meaning and
// is deprecated in favor of flushHeaders(). Detect to avoid a warning.
if (typeof destination.flushHeaders !== 'function') {
// By convention the Zlib streams provide a flush function for this purpose.
destination.flush();
}
// By convention the Zlib streams provide a flush function for this purpose.
// For Express, compression middleware adds this method.
destination.flush();
}
}