{"record":{"id":"1fa0b327c04bac7c","repo":"ComposioHQ/composio","slug":"local-ffi-execution-requires-the-bun-runtime-used","errorCode":null,"errorMessage":"Local FFI execution requires the Bun runtime used by the packaged Composio CLI.","messagePattern":"Local FFI execution requires the Bun runtime used by the packaged Composio CLI\\.","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"ts/packages/cli-local-tools/src/runtime.ts","lineNumber":249,"sourceCode":"): Promise<string> => {\n  if (typeof execution.library === 'string') return execution.library;\n  const resolved = await resolveBundledBinary(context.toolkit, execution.library, {\n    currentPlatform: context.platform,\n  });\n  if (resolved?.exists) return resolved.path;\n  if (execution.library.fallbackCommand) return execution.library.fallbackCommand;\n  throw new Error(\n    `Bundled FFI library ${execution.library.bundledBinary} was not found for ${context.platform}.`\n  );\n};\n\nconst runLocalFfiTool = async (\n  execution: LocalFfiExecution,\n  input: Record<string, unknown>,\n  context: LocalExecutionContext\n): Promise<LocalExecutionResult> => {\n  if (!isBun) {\n    throw new Error(\n      'Local FFI execution requires the Bun runtime used by the packaged Composio CLI.'\n    );\n  }\n\n  const { dlopen, FFIType } = (await import('bun:ffi')) as typeof import('bun:ffi');\n  const libraryPath = await resolveFfiLibraryPath(execution, context);\n  const bindings = Object.fromEntries(\n    Object.entries(execution.symbols).map(([name, symbol]) => [\n      name,\n      {\n        args: symbol.args.map(type => FFIType[ffiTypeMap[type] as keyof typeof FFIType]),\n        returns: FFIType[ffiTypeMap[symbol.returns] as keyof typeof FFIType],\n      },\n    ])\n  );\n  const library = dlopen(libraryPath, bindings);\n  const handle: LocalFfiLibraryHandle = {\n    path: libraryPath,","sourceCodeStart":231,"sourceCodeEnd":267,"githubUrl":"https://github.com/ComposioHQ/composio/blob/64b1b85502b1beeb2379e6c9e8bf1104504fa637/ts/packages/cli-local-tools/src/runtime.ts#L231-L267","documentation":"FFI execution uses bun:ffi, which only exists in the Bun runtime that the packaged Composio CLI is built on. If the code is running under Node.js (or any non-Bun runtime), the isBun check fails and execution is refused before importing bun:ffi.","triggerScenarios":"Importing and executing a local FFI tool from a Node.js script or from tsx/jest; running the CLI unpackaged under node; test runners that execute under Node.","commonSituations":"SDK consumers embedding cli-local-tools in a Node app; unit tests run with node-based runners hitting FFI tools.","solutions":["Run the code under the packaged Composio CLI (Bun-based)","Use bun or bun test to execute code paths that use FFI tools","Avoid FFI-based local tools in Node-only environments; prefer command-based tools"],"exampleFix":"// before: node script.js  (FFI tool)\n// after: bun run script.ts  (or use the packaged composio CLI)","handlingStrategy":"type-guard","validationCode":"const canFfi = typeof (globalThis as any).Bun !== 'undefined';","typeGuard":"const isBunRuntime = (): boolean => typeof (globalThis as { Bun?: unknown }).Bun !== 'undefined';","tryCatchPattern":"try { ... } catch (e) { if (e.message.includes('requires the Bun runtime')) useCommandToolInstead(); }","preventionTips":["Run FFI-dependent code under the packaged CLI or bun","Skip FFI tools in Node-only test suites"],"tags":["ffi","bun","runtime","local-tools"],"backgroundTag":"unsupported-runtime","analyzedSha":"64b1b85502b1beeb2379e6c9e8bf1104504fa637","analyzedAt":"2026-08-28T15:39:33.623Z","schemaVersion":2},"datasetVersion":"2026-08-28T16:17:29.566Z"}