fix: plugins that ctx.stop() before await-ing cannot send 404
Massimo Melina committed
Mar 16, 2025 at 15:15 UTC
767dbc240ec9b454447db7f80505f65fb84a1288
1 file changed
+2
-2
src/plugins.ts
+2
-2
@@ -187,7 +187,7 @@ export const pluginsMiddleware: Koa.Middleware = async (ctx, next) => {
187
warnOnce(`plugin ${id} is using deprecated API (return true on middleware) and may not work with future versions (check for an update to "${id}")`)
188
}
189
// don't just check ctx.isStopped, as the async plugin that called ctx.stop will reach here after sync ones
190
- if (res === true && !ctx.pluginBlockedRequest)
190
+ if (ctx.isStopped && !ctx.pluginBlockedRequest)
191
console.debug("plugin blocked request", ctx.pluginBlockedRequest = id)
192
if (typeof res === 'function')
193
after[id] = res
@@ -197,7 +197,7 @@ export const pluginsMiddleware: Koa.Middleware = async (ctx, next) => {
197
}
198
}))
199
// expose public plugins' files`
200
- if (!ctx.pluginBlockedRequest) {
200
+ if (!ctx.isStopped) {
201
const { path } = ctx
202
if (path.startsWith(PLUGINS_PUB_URI)) {
203
const a = path.substring(PLUGINS_PUB_URI.length).split('/')