You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
import{Context}from'cordis'constctx=newContext()// load a sus plugin that often gets exception when disposeconstfork=ctx.plugin((ctx)=>{console.log('parent load!')ctx.on('dispose',()=>{console.log('parent dispose')thrownewError("Something went wrong here")})ctx.plugin({// any disposable register after the dispose handler upside is ok, // use a plugin with dispose handler as an example.name: 'other-disposables',apply(ctx: Context){console.log('sub load!')ctx.on('dispose',()=>{console.log('sub dispose')// never calls})}})})ctx.start().then()// In Koishi, stop a plugin run in ensure(), // exceptions will be caught, Koishi won't crash// You won't see any exception output, because no one ctx.on 'internal/warning' event to handle itctx.scope.ensure(async()=>{fork.dispose()})// try to dispose againfork.dispose()// checks status here, so it does nothing here
Describe the bug
当你在某些框架函数,
如
ctx.on('dispose', ()=>{/*...*/})
传入的 callback 中出现报错,将会导致后续 dispose 操作不会执行,且再次 dispose 不会继续执行后续 dispose 操作 (在 dispose 前判断了 插件状态)
Steps to reproduce
Expected behavior
catch 这个异常,继续执行后续 dispose 操作
部分顺序调用或调用到用户函数后续包含副作用处理(console handlers, emit等 callback 的都建议加上 ensure 等 catch 方法防止报错崩溃
Screenshots
No response
Versions
Additional context
No response
The text was updated successfully, but these errors were encountered: