Skip to content

require("ws") breaks Cloudflare Workers #1122

@ZachHandley

Description

@ZachHandley

Posting here because I am frustrated with this

There is an SSR implementation, but it's only been tested on NextJs, so when I run it on Cloudflare with SSR, it says:

✘ [ERROR] Build failed with 1 error:

  ✘ [ERROR] Could not resolve "ws"
  
      .wrangler/tmp/pages-26WKBT/chunks/MainLayout_DoaPMGBA.mjs:176179:239:
        176179 │ ...<"u"?self.WebSocket:require("ws"),w$7=()=>typeof WebSocket<...
               ╵                                ~~~~
  
    You can mark the path "ws" as external to exclude it from the bundle, which will remove this
  error and leave the unresolved path in the bundle. You can also surround this "require" call with
  a try/catch block to handle this failure at run-time instead of bundle-time

This is because the crossmint/client-sdk-react-ui for some reason has a top-level require of "websockets", which, Cloudflare does not provide as it is not Node

Can we get an edge runtime, or maybe remove that final require and disable websockets / check for their availability or something?

This is using Astro SSR

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions