How do you sandbox untrusted code in a Cloudflare worker?

Is there a way to sandbox untrusted code in a Cloudflare worker? I have tried several NPM packages, but all have thrown errors or just not worked.

Whats the use case?

allowing user-generated code to run inside the worker

Code generation is blocked in Cloudflare Workers, so you won’t be able to use eval() or new Function(). For running user-generated code, you might want to take a look at Workers for Platforms.

2 Likes

This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.