Closed TimeBather closed 2 years ago
不管是使用QQ频道Adapter还是Sandbox模拟都会有这个问题
koishi start [I] app Koishi/4.5.2 [I] app apply plugin console [I] app apply plugin logger [I] app apply plugin manager [I] app apply plugin status [I] app apply plugin database-mysql [I] app apply plugin dataview [I] app apply plugin chat [I] app apply plugin adapter-onebot [I] app apply plugin adapter-qqguild [I] app apply plugin echo [I] app apply plugin sandbox
"@koishijs/plugin-adapter-discord": "^2.0.8", "@koishijs/plugin-adapter-onebot": "^4.1.6", "@koishijs/plugin-adapter-qqguild": "1.1.2", "@koishijs/plugin-adapter-telegram": "^2.2.2", "@koishijs/plugin-auth": "1.1.2", "@koishijs/plugin-chat": "1.2.3", "@koishijs/plugin-console": "^3.2.5", "@koishijs/plugin-database-mysql": "4.2.0", "@koishijs/plugin-dataview": "^1.2.2", "@koishijs/plugin-echo": "1.1.0", "@koishijs/plugin-eval": "4.0.4", "@koishijs/plugin-logger": "^1.2.2", "@koishijs/plugin-manager": "^1.7.0", "@koishijs/plugin-sandbox": "1.1.0", "@koishijs/plugin-status": "^5.3.5", "koishi": "^4.5.2"
[W] mysql INSERT INTO `channel` (`flag`,`assignee`,`guildId`,`locale`,`name`,`activity`,`platform`,`id`) VALUES (0, '109*****', '210*******', '', '', '{}', 'qqguild', '541****') [W] app ER_DUP_ENTRY: Duplicate entry '5413659-qqguild' for key 'PRIMARY' at MysqlDatabase.query (/www/wwwroot/two-dimension-bot/node_modules/@koishijs/plugin-database-mysql/lib/index.js:264:19) at MysqlDatabase.create (/www/wwwroot/two-dimension-bot/node_modules/@koishijs/plugin-database-mysql/lib/index.js:396:31) at processTicksAndRejections (internal/process/task_queues.js:95:5) [W] mysql INSERT INTO `channel` (`flag`,`assignee`,`guildId`,`locale`,`name`,`activity`,`platform`,`id`) VALUES (0, '1094*****', '2101642******', '', '', '{}', 'qqguild', '21016*******')
[W] mysql INSERT INTO `channel` (`flag`,`assignee`,`guildId`,`locale`,`name`,`activity`,`platform`,`id`) VALUES (0, 'sandbox', '#', '', '', '{}', 'sandbox', '#') [W] session /test ER_DUP_ENTRY: Duplicate entry '#-sandbox' for key 'PRIMARY' at MysqlDatabase.query (/www/wwwroot/two-dimension-bot/node_modules/@koishijs/plugin-database-mysql/lib/index.js:264:19) at MysqlDatabase.create (/www/wwwroot/two-dimension-bot/node_modules/@koishijs/plugin-database-mysql/lib/index.js:396:31) at processTicksAndRejections (internal/process/task_queues.js:95:5) Middleware stack:
这个似乎在多个平台上都有复现,可能和Koishi的用户系统实现有关?
证实这个bug是由于ObserveChannel函数被调用两次产生的,第一次是由App的Process函数调用,第二次是由chat插件调用,chat插件调用位置如下: https://github.com/koishijs/koishi/blob/master/plugins/frontend/chat/src/index.ts#L71
ObserveChannel
不管是使用QQ频道Adapter还是Sandbox模拟都会有这个问题
复现方式
Environment
Log: