Skip to content

Instantly share code, notes, and snippets.

@sentientwaffle
Created November 20, 2013 18:03
Show Gist options
  • Save sentientwaffle/7567970 to your computer and use it in GitHub Desktop.
Save sentientwaffle/7567970 to your computer and use it in GitHub Desktop.
This is a (failing) test for node-spdy@1.16.7. The push streams arrive after the "foo" write, even though the "foo" write occured after the push stream was closed.
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