Custom limits
Custom limits allow you to programmatically enforce limits on the dynamic Worker's resource usage. You can set limits for the maximum CPU time and number of subrequests per invocation. If a dynamic Worker hits either of these limits, it will immediately throw an exception.
Custom limits can be specified as part of the worker code:
const worker = env.LOADER.get("my-worker", async () => { return { compatibilityDate: "$today", mainModule: "index.js", modules: { "index.js": code }, limits: { cpuMs: 10, subRequests: 5 }, };});They can also be specified as part of the getEntrypoint() call:
// get the worker's default entrypoint with custom limits// if limits were already specified as part of the worker code, the lower of the two limits is usedconst entrypoint = worker.getEntrypoint(null, { limits: { cpuMs: 10, subRequests: 5 } });await entrypoint.fetch(...);