koishijs / koishi

Cross-platform chatbot framework made with love
https://koishi.chat
MIT License
4.53k stars 246 forks source link

Bug: 重载 koishi-plugin-puppeteer出现报错 #1401

Open CrystalSight opened 6 months ago

CrystalSight commented 6 months ago

Describe the bug

重载koishi-plugin-puppeteer出现报错

Steps to reproduce

更改koishi-plugin-puppeteer配置后重载,或停用后再启用

另:借曾经一个issues #1105中的代码进行了复现

Expected behavior

插件可正常运行

Screenshots

报错日志

2024-05-18 07:38:45 [E] app Error: service component:html has been registered
                            at Object.set (/koishi/node_modules/@cordisjs/core/lib/index.cjs:944:13)
                            at Proxy.component (/koishi/node_modules/@satorijs/core/lib/index.cjs:641:21)
                            at Puppeteer.start (/koishi/node_modules/koishi-plugin-puppeteer/lib/index.js:60:18)
                            at runNextTicks (node:internal/process/task_queues:60:5)
                            at process.processImmediate (node:internal/timers:449:9)
                            at async /koishi/node_modules/@cordisjs/core/lib/index.cjs:1077:7

#1105中的复现代码

import { Context, Schema, h } from 'koishi'

export const name = 'checkbug'

export interface Config { }

export const Config: Schema<Config> = Schema.object({})

export function apply(ctx: Context) {
  ctx.component('raw', (attr, children, session) => {
    return h('text', { content: children.join('') })
  })
}

复现报错

2024-05-20 13:26:05 [I] loader apply plugin checkbug:j46b69
2024-05-20 13:26:12 [I] loader unload plugin checkbug:j46b69
2024-05-20 13:26:13 [I] loader apply plugin checkbug:j46b69
2024-05-20 13:26:13 [E] app Error: service component:raw has been registered
                            at Object.set (D:\Doc\dev\koishi-app\node_modules\cordis\node_modules\@cordisjs\core\src\context.ts:238:13)       
                            at Proxy.component (D:\Doc\dev\koishi-app\node_modules\@satorijs\core\src\index.ts:155:21)
                            at Object.apply (D:\Doc\dev\koishi-app\external\checkbug\src\index.ts:10:7)
                            at MainScope.apply (D:\Doc\dev\koishi-app\node_modules\cordis\node_modules\@cordisjs\core\src\scope.ts:395:26)    
                            at <anonymous> (D:\Doc\dev\koishi-app\node_modules\cordis\node_modules\@cordisjs\core\src\scope.ts:422:49)        
                            at MainScope.ensure (D:\Doc\dev\koishi-app\node_modules\cordis\node_modules\@cordisjs\core\src\scope.ts:151:18)   
                            at MainScope.start (D:\Doc\dev\koishi-app\node_modules\cordis\node_modules\@cordisjs\core\src\scope.ts:422:12)    
                            at MainScope.init (D:\Doc\dev\koishi-app\node_modules\cordis\node_modules\@cordisjs\core\src\scope.ts:201:12)     
                            at MainScope (D:\Doc\dev\koishi-app\node_modules\cordis\node_modules\@cordisjs\core\src\scope.ts:340:12)
                            at Proxy.plugin (D:\Doc\dev\koishi-app\node_modules\cordis\node_modules\@cordisjs\core\src\registry.ts:163:15)

Versions

Chrome版本 124.0.6367.158(正式版本) (64 位)

System: OS: Windows 11 10.0.22631 CPU: (20) x64 13th Gen Intel(R) Core™ i9-13900H

Binaries: Node: 20.12.1 Yarn: 4.1.1

Koishi: Core: 4.17.6 Console: 5.28.4

Additional context

No response