Skip to content

Commit

Permalink
Revert "Fix cleanup to be consistent across node releases"
Browse files Browse the repository at this point in the history
This reverts commit 50ceba6.

This change caused a regression in the hapi test suite.
  • Loading branch information
cjihrig committed Aug 25, 2020
1 parent 6d7269d commit ea52b07
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 23 deletions.
13 changes: 9 additions & 4 deletions lib/request.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,7 @@ exports = module.exports = internals.Request = class extends Stream.Readable {

constructor(options) {

super({
emitClose: !!(options.simulate && options.simulate.close),
autoDestroy: true // This is the default in node 14+
});
super();

// options: method, url, payload, headers, remoteAddress

Expand Down Expand Up @@ -139,11 +136,19 @@ exports = module.exports = internals.Request = class extends Stream.Readable {
this.emit('error', new Error('Simulated'));
}

if (this._shot.simulate.close) {
this.emit('close');
}

if (this._shot.simulate.end !== false) { // 'end' defaults to true
this.push(null);
}
});
}

destroy() {

}
};


Expand Down
4 changes: 4 additions & 0 deletions lib/response.js
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,10 @@ exports = module.exports = internals.Response = class extends Http.ServerRespons
this.emit('finish');
}

destroy() {

}

addTrailers(trailers) {

for (const key in trailers) {
Expand Down
19 changes: 0 additions & 19 deletions test/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -562,25 +562,6 @@ describe('_read()', () => {
expect(res.payload).to.equal(body);
});

it('supports async iteration', async () => {

const dispatch = async function (req, res) {

let buffer = '';
for await (const chunk of req) {
buffer = buffer + chunk.toString();
}

res.writeHead(200, { 'Content-Length': 0 });
res.end(buffer);
req.destroy();
};

const body = 'something special just for you';
const res = await Shot.inject(dispatch, { method: 'get', url: '/', payload: body });
expect(res.payload).to.equal(body);
});

it('simulates split', async () => {

const dispatch = function (req, res) {
Expand Down

0 comments on commit ea52b07

Please sign in to comment.