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: Vercel Deployment user_preferences_bindings_wasm_bg.wasm not found #612

Closed
HadiKhai opened this issue May 17, 2024 · 1 comment
Closed
Assignees
Labels
bug Something isn't working

Comments

@HadiKhai
Copy link

HadiKhai commented May 17, 2024

Describe the bug

Hello everyone!

I have a nextjs (appDir) application inside an nx monorepo. I was getting the user_preferences_bindings_wasm_bg.wasm error on development and builds

Then I checked the xmtp-nextjs example (xmtp next.config.js) and I adapted it to my monorepo

if (isServer) {
  if (!dev) {
    config.plugins.push(
      new CopyPlugin({
        patterns: [
          {
            context: "../../dist/apps/app/.next/server",
            to: "./app/[name][ext]",
            from: "../../../../../node_modules/@xmtp/user-preferences-bindings-wasm/dist/node",
            filter: (resourcePath) => resourcePath.endsWith(".wasm"),
          },
        ],
      }),
    );
    config.plugins.push(
      new CopyPlugin({
        patterns: [
          {
            context: "../../dist/apps/app/.next/server",
            to: "./chunks/[name][ext]",
            from: "../../../../../node_modules/@xmtp/user-preferences-bindings-wasm/dist/node",
            filter: (resourcePath) => resourcePath.endsWith(".wasm"),
          },
        ],
      }),
    );
  } else {
    config.plugins.push(
      new CopyPlugin({
        patterns: [
          {
            context: ".next/server",
            to: "./vendor-chunks/[name][ext]",
            from: "../../../../node_modules/@xmtp/user-preferences-bindings-wasm/dist/node",
            filter: (resourcePath) => resourcePath.endsWith(".wasm"),
          },
        ],
      }),
    );
  }
}
return config

With this adjustment both the development environment and the builds work fine, but then when I deployed the app to vercel I am getting the error below on async page (server components)

Error: ENOENT: no such file or directory, open '/var/task/dist/apps/app/.next/server/chunks/user_preferences_bindings_wasm_bg.wasm'
    at Object.openSync (node:fs:596:3)
    at Object.readFileSync (node:fs:464:35)
    at 29637 (/var/task/dist/apps/app/.next/server/chunks/2768.js:1:260264)
    at t (/var/task/dist/apps/app/.next/server/webpack-runtime.js:1:143)
    at 92174 (/var/task/dist/apps/app/.next/server/chunks/2768.js:1332:363665)
    at t (/var/task/dist/apps/app/.next/server/webpack-runtime.js:1:143)
    at 9775 (/var/task/dist/apps/app/.next/server/chunks/2768.js:1332:227208)
    at t (/var/task/dist/apps/app/.next/server/webpack-runtime.js:1:143)
    at 83770 (/var/task/dist/apps/app/.next/server/chunks/2174.js:3:6625)
    at t (/var/task/dist/apps/app/.next/server/webpack-runtime.js:1:143) {
  errno: -2,
  syscall: 'open',
  code: 'ENOENT',
  path: '/var/task/dist/apps/app/.next/server/chunks/user_preferences_bindings_wasm_bg.wasm',
  digest: '1622321325'
}

Expected behavior

No response

Steps to reproduce the bug

No response

Tasks

Preview Give feedback
No tasks being tracked yet.
@HadiKhai HadiKhai added the bug Something isn't working label May 17, 2024
@HadiKhai
Copy link
Author

Turns out it was caused by the Vercel Deployment Protection on preview routes (Vercel Authentication), when I deployed it to production the error is gone

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