Hi, since few days some of my users started receiving Worker exceeded resource limits (error code 1102) and I wonder the reason of that. I’m using Workers Bundled (paid) and my worker essentially boils down to:
addEventListener('fetch', event => {
event.respondWith(eventHandler(event))
})
async function eventHandler(event) {
const resp = await fetch('some url')
return new Response(resp.body, {
headers: {
// some headers added
}
})
}
I’m passing response body to new response and add some headers, I also use built-in crypto to sign url (crypto.subtle.sign('HMAC.... but nothing more.
In this case even if not manipulating response body of fetch response, does it still count towards CPU quota? Some of the returned CSV files can be rather large (500MB - 2GB) and perhaps that is causing the issue? Thanks!
You’d have to stream the response from the source to your target/client without letting the Worker handle anything. You can’t for example assign it to a variable, it will eat the CPU instantly.
There’s not a lot of documentation on streaming, but there’s some sample code here: