hopefully last fix for request ended logic

This commit is contained in:
Jonatan Nilsson 2021-10-11 03:16:40 +00:00
parent 3b7af0f290
commit 76b3852aeb
2 changed files with 4 additions and 11 deletions

View file

@ -393,17 +393,17 @@ export class Flaska {
req.on('error', (err) => { req.on('error', (err) => {
this._onreqerror(err, ctx) this._onreqerror(err, ctx)
this.requestEnded(ctx)
}) })
res.on('error', (err) => { res.on('error', (err) => {
this._onreserror(err, ctx) this._onreserror(err, ctx)
}) })
req.on('aborted', function() { req.on('aborted', () => {
ctx.aborted = true ctx.aborted = true
})
req.on('close', () => {
this.requestEnded(ctx) this.requestEnded(ctx)
}) })
res.on('finish', () => { res.on('finish', () => {
this.requestEnded(ctx) this.requestEnded(ctx)
}) })

View file

@ -22,7 +22,7 @@ t.describe('#requestStart()', function() {
flaska.requestEnd = function(err, ctx) { flaska.requestEnd = function(err, ctx) {
try { try {
assert.ok(err) assert.ok(err)
assert.strictEqual(assertReq.on.callCount, 3) assert.strictEqual(assertReq.on.callCount, 2)
assert.strictEqual(assertRes.on.callCount, 2) assert.strictEqual(assertRes.on.callCount, 2)
@ -53,13 +53,6 @@ t.describe('#requestStart()', function() {
assertReq.on.secondCall[1]() assertReq.on.secondCall[1]()
assert.strictEqual(ctx.aborted, true) assert.strictEqual(ctx.aborted, true)
assert.strictEqual(assertReq.on.thirdCall[0], 'close')
assert.strictEqual(typeof(assertReq.on.thirdCall[1]), 'function')
assert.strictEqual(onEnded.callCount, 1)
assertReq.on.thirdCall[1]()
assert.strictEqual(onEnded.callCount, 2)
assert.strictEqual(onEnded.secondCall[0], ctx)
// Test abort and close // Test abort and close
cb() cb()