Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Loader 将子插件 dispose 视为整个插件 dispose #19

Open
CyanChanges opened this issue Feb 13, 2025 · 0 comments
Open

Loader 将子插件 dispose 视为整个插件 dispose #19

CyanChanges opened this issue Feb 13, 2025 · 0 comments

Comments

@CyanChanges
Copy link
Contributor

简述
将子插件上下文销毁将导致上层上下文对应的 loader entry 被 disable

复现

// index.js
export default (ctx) => {
  const scope = ctx.plugin(() => { /* do something */ })
  scope.dispose()
}

输出

[I] loader unload plugin cordis-plugin-test
[I] loader apply plugin cordis-plugin-test

配置中插件插件直接被标记为 disable, 即使改插件其实没有被 dispose
(甚至在 unload 在 apply 之前)

额外内容((
使用以下代码, 启用 insight 插件并打开控制台即可触发

export default (ctx) => {
  const scope = ctx.plugin(() => { /* do something */ })
  scope.dispose()
  ctx.scope.dispose() // +
}
[E] insight AssertionError [ERR_ASSERTION]: The expression evaluated to a falsy value:
    
      assert(uid !== null)
    
        at addNode (/tmp/cordis-app/node_modules/@cordisjs/plugin-insight/src/index.ts:88:7)
        at Entry.getGraph (/tmp/cordis-app/node_modules/@cordisjs/plugin-insight/src/index.ts:140:9)
        at Object.apply (/tmp/cordis-app/node_modules/@cordisjs/core/src/utils.ts:132:28)
        at Entry.toJSON (/tmp/cordis-app/node_modules/@cordisjs/plugin-webui/src/shared/entry.ts:79:46)
        at <anonymous> (/tmp/cordis-app/node_modules/@cordisjs/plugin-webui/src/shared/client.ts:22:56)
        at <anonymous> (/tmp/cordis-app/node_modules/cosmokit/src/misc.ts:26:81)
        at Array.map (<anonymous>)
        at mapValues (/tmp/cordis-app/node_modules/cosmokit/src/misc.ts:26:52)
        at new Client (/tmp/cordis-app/node_modules/@cordisjs/plugin-webui/src/shared/client.ts:22:16)
        at NodeWebUI.accept (/tmp/cordis-app/node_modules/@cordisjs/plugin-webui/src/shared/index.ts:43:20)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant