Skip to content

Commit

Permalink
Fixes marko-js-archive/async-writer#3 - flush is deprecated in Outgoi…
Browse files Browse the repository at this point in the history
…ngMessage
  • Loading branch information
patrick-steele-idem committed Feb 26, 2016
1 parent b355f1f commit 4ce1424
Showing 1 changed file with 20 additions and 0 deletions.
20 changes: 20 additions & 0 deletions runtime/loader.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,26 @@ if (process.env.hasOwnProperty('MARKO_HOT_RELOAD')) {
// enable browser-refresh
require('../browser-refresh').enable();

function fixFlush() {
try {
var OutgoingMessage = require('http').OutgoingMessage;
if (OutgoingMessage.prototype.flush && OutgoingMessage.prototype.flush.toString().indexOf('deprecated') !== -1) {
// Yes, we are monkey-patching http. This method should never have been added and it was introduced on
// the iojs fork. It was quickly deprecated and I'm 99% sure no one is actually using it.
// See:
// - https://github.com/marko-js/async-writer/issues/3
// - https://github.com/nodejs/node/issues/2920
//
// This method causes problems since marko looks for the flush method and calls it found.
// The `res.flush()` method is introduced by the [compression](https://www.npmjs.com/package/compression)
// middleware, but, otherwise, it should typically not exist.
delete require('http').OutgoingMessage.prototype.flush;
}
} catch(e) {}
}

fixFlush();

function loadSource(templatePath, compiledSrc) {
var templateModulePath = templatePath + '.js';

Expand Down

0 comments on commit 4ce1424

Please sign in to comment.