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

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

Open
davedbase opened this issue Aug 10, 2021 · 2 comments
Open

Comments

@davedbase
Copy link

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.

@davedbase
Copy link
Author

According to a response on the CF community forum we can identify CFW runtime by checking for: caches.default or WebSocketPair. I could submit a PR to account for this if there's a chance it would be accepted.

@bdougherty
Copy link
Contributor

I think maybe the way to go here is to replace that check with a check for document? Does the CF environment have that? Happy to review a PR to fix this!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants