Skip to content

Incompatibility issue in production build with cloudflare worker from 3.0.1 #112

@vnphanquang

Description

@vnphanquang

Description

Hi there, thank you for the good work. During some maintenance update I discovered @paralleldrive/cuid2, starting from 3.0.1, cause crash in my production build, targeted Cloudflare worker environment, using their official vite-plugin. The server log is as follow, although it is not very helpful:

✘ [ERROR] service core:user:cloudflare-vite-get-started: Uncaught Error: Disallowed operation called within global scope. Asynchronous I/O (ex: fetch() or connect()), setting a timeout, and generating random values are not allowed within global scope. To fix this error, perform this operation within a handler. https://developers.cloudflare.com/workers/runtime-apis/handlers/

Reproduction

Please see https://github.com/vnphanquang/cloudflare-worker-vite-plugin-cuid2 and its README for detailed steps to reproduce. I did not test if this causes similar issue without the vite-plugin (running wrangler directly).

I suspect this is due to some ESM syntax introduced recently, or some imported module with side effects. But since there is no entry for 3.0.1 in the CHANGELOG, I'm not able to investigate further at this point, sorry.

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