Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bug: Worker error on line undefined in "undefined" #865

Open
saqlain1020 opened this issue Mar 11, 2025 · 2 comments
Open

Bug: Worker error on line undefined in "undefined" #865

saqlain1020 opened this issue Mar 11, 2025 · 2 comments
Labels
bug Something isn't working

Comments

@saqlain1020
Copy link

saqlain1020 commented Mar 11, 2025

Describe the bug

I created a Vite project, and tried creating a xmtp client, i am getting error Worker error on line undefined in "undefined"

Also in vite terminal i am getting this warning

The file does not exist at "C:/...../node_modules/.vite/deps/workers/client?worker_file&type=module" which is in the optimize deps directory. The dependency might be incompatible with the dep optimizer. Try adding it to `optimizeDeps.exclude`.

Package.json

{
  "name": "blockchain-test-ui",
  "private": true,
  "version": "0.0.0",
  "type": "module",
  "scripts": {
    "dev": "vite",
    "build": "tsc && vite build",
    "lint": "biome check .",
    "preview": "vite preview"
  },
  "dependencies": {
    "@layerzerolabs/scan-client": "^0.0.8",
    "@rainbow-me/rainbowkit": "^2.2.3",
    "@tanstack/react-query": "5.45.1",
    "@xmtp/browser-sdk": "^0.0.23",
    "@xmtp/node-sdk": "^0.0.47",
    "axios": "^1.7.9",
    "react": "^18.3.1",
    "react-dom": "^18.3.1",
    "viem": "^2.22.21",
    "vite-tsconfig-paths": "^5.1.4",
    "wagmi": "^2.14.9"
  },
  "devDependencies": {
    "@types/react": "^18.3.1",
    "@types/react-dom": "^18.3.0",
    "@vitejs/plugin-react": "^4.2.1",
    "@wagmi/cli": "latest",
    "buffer": "^6.0.3",
    "typescript": "^5.4.5",
    "vite": "^5.2.11"
  }
}

tsconfig.json

  "compilerOptions": {
    "target": "ES2020",
    "useDefineForClassFields": true,
    "lib": ["ES2020", "DOM", "DOM.Iterable"],
    "module": "ESNext",
    "skipLibCheck": true,

    /* Bundler mode */
    "moduleResolution": "bundler",
    "allowImportingTsExtensions": true,
    "resolveJsonModule": true,
    "isolatedModules": true,
    "noEmit": true,
    "jsx": "react-jsx",

    /* Linting */
    "strict": true,
    "noUnusedLocals": true,
    "noUnusedParameters": true,
    "noFallthroughCasesInSwitch": true
  },
  "include": ["src"],
  "references": [{ "path": "./tsconfig.node.json" }]
}

tsconfig.node.json

{
  "compilerOptions": {
    "composite": true,
    "skipLibCheck": true,
    "module": "ESNext",
    "moduleResolution": "bundler",
    "allowSyntheticDefaultImports": true
  },
  "include": ["vite.config.ts"]
}

vite.config.js

import { defineConfig } from "vite";
import tsconfigPaths from "vite-tsconfig-paths";

// https://vitejs.dev/config/
export default defineConfig({
  plugins: [tsconfigPaths(), react()],
  optimizeDeps: {
    exclude: ["@xmtp/wasm-bindings"],
  },
});

Expected behavior

No response

Steps to reproduce the bug

Add browser-sdk in existing vite project using yarn and try creating a client.

Reproduction:-

https://stackblitz.com/edit/vitejs-vite-sgimdayn?file=src%2FApp.tsx

@saqlain1020 saqlain1020 added the bug Something isn't working label Mar 11, 2025
@rygine
Copy link
Collaborator

rygine commented Mar 11, 2025

hey @saqlain1020, thanks for the detailed report. try updating your vite.config.js with this:

  optimizeDeps: {
    exclude: ["@xmtp/wasm-bindings", "@xmtp/browser-sdk"],
    include: ["@xmtp/proto"],
  },

@saqlain1020
Copy link
Author

@rygine Thanks that works, can you update the ReadMe accordinly.
Thanks alot.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants