Bug Report
Environment
- OpenCode version: latest
- Plugin:
opencode-discord-presence v0.2.7
@opencode-ai/plugin: v1.1.44
Error Message
[discord-rpc] Connected to Discord
{
"name": "UnknownError",
"data": {
"message": "TypeError: fn3 is not a function. (In 'fn3(input)', 'fn3' is an instance of Array)\n at <anonymous> (src/plugin/index.ts:87:28)\n at processTicksAndRejections (native:7:39)"
}
}
Description
When using a plugin that exports hooks (chat.message, event), OpenCode's internal plugin system throws an error at src/plugin/index.ts:87:28 stating that fn3 is not a function and that it's actually an Array.
Plugin Code (simplified)
import type { Plugin } from "@opencode-ai/plugin"
export const OpenCodeDiscordPresence: Plugin = async (ctx) => {
// ... setup code ...
return {
"chat.message": async (input) => {
// handle message
},
event: async ({ event }) => {
// handle event
},
}
}
export default OpenCodeDiscordPresence
Expected Behavior
The plugin hooks should be called correctly without type errors.
Actual Behavior
OpenCode's plugin system fails to execute the hooks, treating them as arrays instead of functions.
Possible Cause
Looking at the @opencode-ai/plugin type definitions, the chat.message hook signature is:
"chat.message"?: (input: {...}, output: {...}) => Promise<void>;
This takes TWO parameters (input and output), but the error suggests there may be an internal issue with how hooks are being collected or called within OpenCode's plugin orchestration layer at src/plugin/index.ts:87.
Additional Context
- The Discord RPC connection succeeds (as shown by the log)
- The error occurs during hook execution, not plugin initialization
- Stack trace points to
src/plugin/index.ts:87:28 in OpenCode's source
- The plugin is exported correctly as both named and default export
Bug Report
Environment
opencode-discord-presencev0.2.7@opencode-ai/plugin: v1.1.44Error Message
Description
When using a plugin that exports hooks (
chat.message,event), OpenCode's internal plugin system throws an error atsrc/plugin/index.ts:87:28stating thatfn3 is not a functionand that it's actually an Array.Plugin Code (simplified)
Expected Behavior
The plugin hooks should be called correctly without type errors.
Actual Behavior
OpenCode's plugin system fails to execute the hooks, treating them as arrays instead of functions.
Possible Cause
Looking at the
@opencode-ai/plugintype definitions, thechat.messagehook signature is:This takes TWO parameters (
inputandoutput), but the error suggests there may be an internal issue with how hooks are being collected or called within OpenCode's plugin orchestration layer atsrc/plugin/index.ts:87.Additional Context
src/plugin/index.ts:87:28in OpenCode's source