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

Add cloudflare worker compatibility #216

Closed

Commits on Sep 10, 2024

  1. Add cloudflare worker compatibility

    See/Fixes dnsimple#215
    
    In existing code, this lib detects the `fetch` API by checking for `window` - however, there are a few more environments where `fetch` is now the native http handlingmethod and this library could work automatically. Namely cloudflare workers (v8 isolates) and Web/Service Workers.
    
    This PR changes the feature detection to also include WorkerGlobalScope environments, which will detect the above cases.
    
    In addition to the detection change, cloudflare workers appear to hoist `require` calls, so this PR also manually hoists the `require` calls that were previously gated behind an early return in the browser case, but wraps them in a try/catch so that if we incorrectly feature detect node, it will preserve the original error and re-throw it once we've passed the feature gate.
    jesseditson committed Sep 10, 2024
    Configuration menu
    Copy the full SHA
    78fc056 View commit details
    Browse the repository at this point in the history