-
Couldn't load subscription status.
- Fork 807
Description
Describe the bug
The @solana-agent-kit/plugin-defi package fails to load due to a dependency conflict with rpc-websockets.
The plugin's dependency chain includes jito-ts which bundles an outdated version of @solana/web3.js (v1.77.4) that expects an old file structure from rpc-websockets that no longer exists in modern versions.
To Reproduce
- Create a new project with
npm init - Install the required packages:
npm install solana-agent-kit @solana-agent-kit/adapter-mcp @solana-agent-kit/plugin-token @solana-agent-kit/plugin-defi - Create an
index.jsfile that imports the DefiPlugin:
import { SolanaAgentKit } from "solana-agent-kit";
import DefiPlugin from "@solana-agent-kit/plugin-defi";
const agent = new SolanaAgentKit(wallet, rpcUrl, options)
.use(DefiPlugin);
- Run node
index.js - See error: Error: Cannot find module 'rpc-websockets/dist/lib/client'
Expected behavior
The DefiPlugin should load successfully without module resolution errors.
Additional context
Error stack trace:
Error: Cannot find module 'rpc-websockets/dist/lib/client'
Require stack:
- node_modules/jito-ts/node_modules/@solana/web3.js/lib/index.cjs.js
- node_modules/jito-ts/dist/sdk/block-engine/types.js
- node_modules/@pythnetwork/solana-utils/lib/jito.js
- node_modules/@drift-labs/sdk/lib/node/oracles/pythPullClient.js
The issue stems from [email protected] bundling @solana/[email protected] internally
This old web3.js version expects rpc-websockets/dist/lib/client.js but modern rpc-websockets (v7.11+) uses .cjs extensions
The dependency chain: @solana-agent-kit/plugin-defi → @drift-labs/sdk → @pythnetwork/pyth-solana-receiver → @pythnetwork/solana-utils → jito-ts → old @solana/web3.js
Workaround: manually copy .cjs files to .js in node_modules/rpc-websockets/dist/lib/
Suggested fix: Update the dependency chain to use compatible versions or add a compatibility layer