Skip to content

🐛 Bug: Browser Build Fails Due to Accidental Inclusion of AWS SDK #2731

@zero8892084

Description

@zero8892084

♻️ Reproduction Steps

Title: Browser Build Fails Due to Accidental Inclusion of AWS SDK via @langchain/core in @copilotkit/runtime@1.10.x

Description:

Hi team,

After upgrading to @copilotkit/runtime@1.10.6, our Vite-based React application fails at runtime in the browser with the following error:
Uncaught SyntaxError: Export 'import_getSSOTokenFromFile2' is not defined in module
This error originates from AWS SDK v3’s Node.js–specific module (@aws-sdk/shared-ini-file-loader), which is being bundled into the browser build.

Root Cause
We traced the dependency chain and found that:

@copilotkit/runtime@1.10.6
└─ @copilotkit/common@1.10.6
└─ @langchain/core@^0.3.0
└─ @aws-sdk/* (Node.js-only modules)
Although @langchain/core may be intended as an optional or backend-only dependency, Vite (and other bundlers) automatically include it during dependency pre-bundling, causing Node.js–specific code (e.g., file system operations for AWS SSO tokens) to be injected into the client-side bundle — which fails in the browser.

This breaks any frontend app using CopilotKit >=1.9.0, even when only using LangGraphAgent (which only needs HTTP/SSE and has no need for LangChain or AWS).

Impact
Frontend apps crash on load in the browser.
The issue persists even with a clean node_modules and cache because Vite re-prebundles the problematic dependencies.
Users cannot use the latest CopilotKit versions without workarounds.
Proposed Fixes
(Recommended) Mark @langchain/core as an optional peer dependency and exclude it from the main bundle.

If LangChain integration is needed, it should be opt-in via a separate package (e.g., @copilotkit/langchain-adapter).
Alternatively, ensure that any LangChain-related code is dynamically imported only in Node.js environments, or provide ESM builds with proper exports conditions that exclude Node.js modules from browser bundles.
At minimum, document this breaking change and provide guidance for frontend users to avoid the issue.
Temporary Workaround
Downgrading to @copilotkit/runtime@1.8.2 resolves the issue, as that version does not depend on @langchain/core.

npm install @copilotkit/runtime@1.8.2 @copilotkit/react-core@1.8.2 @copilotkit/react-ui@1.8.2

Thanks for your great work on CopilotKit! Let me know if you need more details or a minimal reproduction repo.

✅ Expected Behavior

111111

❌ Actual Behavior

After upgrading to @copilotkit/runtime@1.10.6, our Vite-based React application fails at runtime in the browser with the following error:
Uncaught SyntaxError: Export 'import_getSSOTokenFromFile2' is not defined in module
This error originates from AWS SDK v3’s Node.js–specific module (@aws-sdk/shared-ini-file-loader), which is being bundled into the browser build.

𝌚 CopilotKit Version

├── @copilotkit/react-core@1.10.6 -> ./node_modules/.pnpm/@copilotkit+react-core@1.10.6_@types+react@19.2.5_graphql@16.12.0_react-dom@19.2.0_react@19.2.0__react@19.2.0/node_modules/@copilotkit/react-core
├── @copilotkit/react-ui@1.10.6 -> ./node_modules/.pnpm/@copilotkit+react-ui@1.10.6_@types+react@19.2.5_graphql@16.12.0_react-dom@19.2.0_react@19.2.0__react@19.2.0/node_modules/@copilotkit/react-ui
├── @copilotkit/runtime@1.10.6 -> ./node_modules/.pnpm/@copilotkit+runtime@1.10.6_@ag-ui+client@0.0.41_@ag-ui+core@0.0.37_@ag-ui+encoder@0.0.4_b79ede7e685e274932e93c413cfb3a1d/node_modules/@copilotkit/runtime

📄 Logs (Optional)

Uncaught SyntaxError: Export 'import_getSSOTokenFromFile2' is not defined in module (at chunk-YUHLK2RX.js?v=fce810a6:378:3)


export {
  require_os,
  require_path,
  require_crypto,
  ENV_PROFILE,
  getProfileName,
  getSSOTokenFilepath,
  loadSharedConfigFiles,
  loadSsoSessionData,
  parseKnownFiles,
  externalDataInterceptor,
  import_getSSOTokenFromFile2 as import_getSSOTokenFromFile,
  init_dist_es2 as init_dist_es
};
//# sourceMappingURL=chunk-YUHLK2RX.js.map

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions