Can anyone help me understand what my worker is doing there for the first 850ms before it hits kv_getWithMetadata? In my code we are literally just starting the request, checking if the request is cachable (tiny synchronous function), create a cacheKey (tiny synchronous function) and then check in our KV cache if the cachekey exists. I timed these functions and they basically take just <5ms to exectly. Before we hit the env.CACHE_KV.getWithMetadata 850ms pass still though (see screenshot)?!
I tried to debug this in every possible way but I simply cannot make sense of it...
export default {
async fetch(req, env, ctx) {
if (!isCacheableRequest(req)) {
return nextWorker.fetch(req, env, ctx)
}
const cacheKey = getCacheKey(req)
try {
const cached = await env.CACHE_KV.getWithMetadata(cacheKey, "arrayBuffer") => 850ms have already passed here. How?