@ -18,6 +18,9 @@ function monkeyPatchEnd(res) {
let prefix ;
let prefix ;
if ( originalChunk == null || typeof originalChunk === "string" || Buffer . isBuffer ( originalChunk ) ) {
if ( originalChunk == null || typeof originalChunk === "string" || Buffer . isBuffer ( originalChunk ) ) {
if ( ! res . headersSent ) {
// If headers have already been sent, we'll just have to hope that the browser will still look at our appended tag, as we can't change the response size anymore...
// TODO: Make this more robust in the future
let typeHeader = res . getHeader ( "content-type" ) ;
let typeHeader = res . getHeader ( "content-type" ) ;
if ( typeHeader != null && typeHeader . startsWith ( "text/html" ) ) {
if ( typeHeader != null && typeHeader . startsWith ( "text/html" ) ) {
@ -30,6 +33,7 @@ function monkeyPatchEnd(res) {
prefix = reloadClientTag ;
prefix = reloadClientTag ;
}
}
}
// Reset the `end` method back to the original method; we don't need to get in the way anymore
// Reset the `end` method back to the original method; we don't need to get in the way anymore
res . end = end ;
res . end = end ;