Created
May 22, 2016 14:06
-
-
Save Alan01252/efa75907063ff5c5b63df26098f1a06d to your computer and use it in GitHub Desktop.
multiplex memory leak
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var multiplex = require('multiplex'); | |
var debug = require('debug')('test') | |
var plex1 = multiplex(); | |
var plex2 = multiplex() | |
plex1.pipe(plex2); | |
plex2.pipe(plex1); | |
function createStream(name) { | |
var stream = plex1.createSharedStream(name); | |
stream.on("data", function (data) { | |
debug("Got data"); | |
debug(data); | |
}); | |
stream.on("end", function (data) { | |
debug("stream ended"); | |
stream.destroy(); | |
}); | |
var secondStream = plex2.createSharedStream(name); | |
secondStream.on("data", function (data) { | |
debug("second stream got data"); | |
}); | |
secondStream.on("data", function (data) { | |
debug("second stream got end"); | |
secondStream.end(new Buffer("End of this stream")); | |
}); | |
console.log(plex1); | |
debug("x"); | |
stream.end(new Buffer("Hello World")); | |
} | |
createStream("foo"); | |
createStream("bar"); | |
setTimeout(function () { | |
console.log(plex1); | |
}, 1000); | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment