requestEnd: Fix detection on when response is finished
This commit is contained in:
parent
6fe5a7272d
commit
c3b7447024
2 changed files with 12 additions and 1 deletions
|
@ -467,7 +467,7 @@ export class Flaska {
|
|||
if (err) {
|
||||
this._onerror(err, ctx)
|
||||
}
|
||||
if (ctx.req.complete) {
|
||||
if (ctx.res.writableEnded) {
|
||||
return
|
||||
}
|
||||
|
||||
|
|
|
@ -198,6 +198,17 @@ t.describe('#requestEnd()', function() {
|
|||
flaska.requestEnd(null, ctx)
|
||||
})
|
||||
|
||||
t.test('should return immediately if req is finished', function() {
|
||||
let onFinish = function() {
|
||||
throw new Error('should not be called')
|
||||
}
|
||||
const ctx = createCtx({ }, onFinish)
|
||||
ctx.res.writableEnded = true
|
||||
|
||||
let flaska = new Flaska({}, fakerHttp, fakeStream)
|
||||
flaska.requestEnd(null, ctx)
|
||||
})
|
||||
|
||||
const emptyStatuses = [204, 205, 304]
|
||||
|
||||
emptyStatuses.forEach(function(status) {
|
||||
|
|
Loading…
Reference in a new issue