Skip to content

Fails to detect Cloudflare Worker environments (issue with isNode) #745

@davedbase

Description

@davedbase

Expected Behavior

Be able to deploy to Cloudflare Worker without environment error warning.

Actual Behavior

In deploy to the Cloudflare Worker, as the script initializes and prepares to go live, the Wrangler CLI throws an error:

🌀  Running 
✨  Build completed successfully!
🌀  Using namespace for Workers Site "__stage-site-workers_sites_assets"
✨  Success
🌀  Uploading site files
Error: Something went wrong with the request to Cloudflare...
Uncaught Error: Sorry, the Vimeo Player API is not available in this browser.
  at line 911
 [API code: 10021]

This is likely due to the fact that a Cloudflare Worker is not a node environment. The current detection method for a Node environment fails in this case and incorrectly blocks the deployment. To temporarily deploy I managed to uncomment the following at the bottom of player.js

if (!isNode) {
  // screenfull = initializeScreenfull();
  // initializeEmbeds();
  // resizeEmbeds();
}

Steps to Reproduce

Import player into an SSR script with import Player from "@vimeo/player"; then attempt a deployment to a live worker.

Possible solutions

I've been looking for a way to detect a CF environment since it's different than Node. I'm thinking that isNode could likely be extended to include this check. I've opened a thread within the CF community asking what an appropriate solution might be: https://community.cloudflare.com/t/how-to-detect-the-cloudflare-worker-runtime/293715

If anyone else has stumbled on this issue or is familiar with CF Workers, please weight in. I'd be happy to make a PR once this is known + tested.

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