You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Not able to run unleash on cloudflare workers (v8) #725
I want to use unleash together with Gitlab Feature Flags (in a Vue Nuxt.js application). Therefore i created a serverside endpoint in our nuxt app (nuxt runs a nitro server) that uses unleash-client. Everything works flawlessly local.
When I try to deploy it to our Cloudflare pages, the deployment fails with:
Error: Failed to publish your Function. Got error: Uncaught TypeError: Class extends value #<Object> is not a constructor or null
at chunks/nitro/nitro.mjs:1:222837
I think the reason is that Cloudflare workers run on V8 and not Node.js. Apparently unleash-client relies on some node API's that V8 does not provide and therefore it doesn't work.
Ofc this is not a bug from your side, but I wonder if there is a way to polyfill/fix this or is there another unleash approach to cloudflare?
Or is it impossible to use Unleash together with Cloudflare?
Hi, @exophunk it should be possible, but it requires some refactoring. Right now this is not top of our priority list. If you'd like to contribute with a PR we'll happily review it. Maybe (just maybe), you'll have to fork this repo and create a cloudflare specific client.
I'm not familiar with pollyfill, but sounds like a way of replacing those v8 functions with other specific functions of the target platform (such as clouflare) at compilation time.
Ideally, we should start by identifying the issues. I believe some common culprits of this issue are:
Imports: require('fs'), require('net'), require('stream'). From a quick search in our codebase fs is used for caching and bootstrapping, and likely 'net' is needed for the strategies mentioned by Tymek.
Use of process: we use it for environment variables (mostly)
Activity
Tymek commentedon Apr 16, 2025
From prior investigations, IP and Hostname strategies are an issue here. I'll try to investigate if we can import relevant dependencies conditionally.
gastonfournier commentedon Jun 16, 2025
Hi, @exophunk it should be possible, but it requires some refactoring. Right now this is not top of our priority list. If you'd like to contribute with a PR we'll happily review it. Maybe (just maybe), you'll have to fork this repo and create a cloudflare specific client.
I'm not familiar with pollyfill, but sounds like a way of replacing those v8 functions with other specific functions of the target platform (such as clouflare) at compilation time.
Ideally, we should start by identifying the issues. I believe some common culprits of this issue are:
require('fs'),require('net'),require('stream'). From a quick search in our codebase fs is used for caching and bootstrapping, and likely'net'is needed for the strategies mentioned by Tymek.process: we use it for environment variables (mostly)But this is just a short list I spent 10' on.