fix: wrong debug log for middleware plugins

Massimo Melina committed Feb 16, 2025 at 11:34 UTC 6958818bc2871997514b3db3c57d66c74c3596ce
1 file changed +2 -1
src/plugins.ts
+2 -1
@@ -161,7 +161,8 @@ export const pluginsMiddleware: Koa.Middleware = async (ctx, next) => {
161 ctx.stop()
162 warnOnce(`plugin ${id} is using deprecated API (return true on middleware) and may not work with future versions (check for an update to "${id}")`)
163 }
164 - if (ctx.isStopped)
164 + // don't just check ctx.isStopped, as the async plugin that called ctx.stop will reach here after sync ones
165 + if (res === true && !ctx.pluginBlockedRequest)
166 console.debug("plugin blocked request", ctx.pluginBlockedRequest = id)
167 if (typeof res === 'function')
168 after[id] = res