Skip to content

Commit fc5ad5e

Browse files
committed
fix: ensure proper cleanup of abort flow control function
1 parent 122792f commit fc5ad5e

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

src/middlewares/abort-flow-control-middleware.ts

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,12 +20,15 @@ export function abortFlowControlMiddleware(): KeqMiddleware {
2020
abort(reason)
2121
}
2222

23-
ctx.global.abortFlowControl[key] = ctx.abort.bind(ctx)
23+
const fn = ctx.abort.bind(ctx)
24+
ctx.global.abortFlowControl[key] = fn
2425

2526
try {
2627
await next()
2728
} finally {
28-
ctx.global.abortFlowControl[key] = undefined
29+
if (ctx.global.abortFlowControl[key] === fn) {
30+
ctx.global.abortFlowControl[key] = undefined
31+
}
2932
}
3033
}
3134
}

0 commit comments

Comments
 (0)