Created
November 20, 2013 18:03
-
-
Save sentientwaffle/7567970 to your computer and use it in GitHub Desktop.
This is a (failing) test for [email protected]. The push streams arrive after the "foo" write, even though the "foo" write occured after the push stream was closed.
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
test('push stream compression race', function(done) { | |
var ops = []; | |
var remaining = 2; | |
pair.client.res.on('data', function(data) { | |
ops.push(['req data', data.toString()]); | |
doneish(); | |
}); | |
agent.once('push', function(req) { | |
req.once('data', function(chunk) { ops.push(['push data', chunk.toString()]); }); | |
req.once('end', function() { | |
ops.push(['push end']); | |
doneish(); | |
}); | |
}); | |
pair.server.res.push('/wtf', {'Content-Encoding': 'gzip'}, function(err, stream) { | |
assert(!err); | |
stream.on('error', function(err) { throw err; }); | |
var gzip = zlib.createGzip(); | |
gzip.pipe(stream); | |
gzip.end('yes, wtf', function() { | |
pair.server.res.write('foo'); | |
}); | |
}); | |
function doneish() { | |
if (--remaining !== 0) { return; } | |
assert.deepEqual(ops, [ | |
['push data', 'yes, wtf'], | |
['push end'], | |
['req data', 'foo'] | |
]); | |
done(); | |
} | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment