Conversation
There was a problem hiding this comment.
Does this actually test the change? As far as I can tell 'abort' was emitted only once even before. Can we have a better test?
There was a problem hiding this comment.
What do you mean? I call abort() twice and 'abort' is only emitted once...
There was a problem hiding this comment.
Yes, that's my point. it works like this even without the changes proposed here, so it is not clear what this is testing.
There was a problem hiding this comment.
'use strict';
const http = require('http');
const server = http.createServer(function(req, res) {
res.flushHeaders();
});
server.listen(function() {
const req = http.get({ port: server.address().port });
req.on('response', function(res) {
const dump = res._dump;
res._dump = function() {
console.log('dump');
dump.apply(res, arguments);
};
req.abort();
req.abort();
req.abort();
req.abort();
});
req.on('abort', function() {
console.log('abort');
});
});'abort' is already emitted only once. The difference is that res._dump() is only called once now. Hope it makes sense.
There was a problem hiding this comment.
Makes sense. Updated. Not pretty but I can't see any other way.
0c9fb90 to
228b7a2
Compare
c41bb9f to
ea27fc4
Compare
| const req = http.get(options, common.mustCall((res) => { | ||
| res._dump = common.mustCall(res._dump.bind(res)); | ||
| res.on('data', (data) => { | ||
| req.abort(); |
There was a problem hiding this comment.
Does it make sense to make this a separate test rather than modifying the existing test? My concern is that the existing test is such a straightforward one and this kind of makes it less obvious what's going on. (There's no comment explaining why req.abort() is being called twice. But also wouldn't we want a test where it is only called once?)
|
This is sorted better by #29192 |
All calls expect the first to
abortshould be a noop.abortevent should not be emitted more than once.Checklist
make -j4 test(UNIX), orvcbuild test(Windows) passes