Skip to content

Conversation

@southpolesteve
Copy link

Cloudflare Workers now permit new Function at module scope, so this removes the blanket disable and rechecks eval availability each time on Cloudflare. This PR has no changes to non-workerd JS runtimes.

When the fast path can compile and run, Workers get the JIT speedup; if Function is blocked (compat flag or runtime error), parsing quietly falls back to the slow path.

@vercel
Copy link

vercel bot commented Nov 19, 2025

@southpolesteve is attempting to deploy a commit to the colinhacks Team on Vercel.

A member of the Team first needs to authorize it.

Comment on lines +386 to +392
const ua = typeof navigator === "undefined" ? undefined : navigator?.userAgent;
const isCloudflare = typeof ua === "string" && ua.includes("Cloudflare");

if (isCloudflare) {
// Cloudflare Workers can vary by compat flag; always re-check.
return canUseFunction();
}
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can check for this directly:

if (globalThis.Cloudflare?.compatibilityFlags?.allow_eval_during_startup)

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah wait – I think I see the problem – even if that flag's enabled, this check might happen at a time other than startup... so you have to check regardless, and can't cache... right?

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

Successfully merging this pull request may close these issues.

2 participants