TypeError: fn3 is not a function in plugin hook execution (src/plugin/index.ts:87) #8095

Closed
opened 2026-02-16 18:09:09 -05:00 by yindo · 1 comment
Owner

Originally created by @Puri12 on GitHub (Jan 30, 2026).

Originally assigned to: @rekram1-node on GitHub.

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
Originally created by @Puri12 on GitHub (Jan 30, 2026). Originally assigned to: @rekram1-node on GitHub. ## 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) ```typescript 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: ```typescript "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
yindo closed this issue 2026-02-16 18:09:09 -05:00
Author
Owner

@github-actions[bot] commented on GitHub (Jan 30, 2026):

This issue might be related to #7792, which has the same 'fn3 is not a function' error but in the context of custom provider initialization. Both errors appear to stem from the same root cause in how OpenCode's plugin/provider system executes dynamically loaded functions. Please check #7792 for additional context and workarounds.

@github-actions[bot] commented on GitHub (Jan 30, 2026): This issue might be related to #7792, which has the same 'fn3 is not a function' error but in the context of custom provider initialization. Both errors appear to stem from the same root cause in how OpenCode's plugin/provider system executes dynamically loaded functions. Please check #7792 for additional context and workarounds.
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: anomalyco/opencode#8095