#Worker performance issue on start

5 messages · Page 1 of 1 (latest)

weary bramble
#

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?
last wasp
#

Is your worker several megabytes of JS?

weary bramble
#

I am not sure to be honest. Its a nextjs application. How could I check that?

last wasp
#

Itll tell you when you run the deploy command

weary bramble
#

Total Upload: 4.12 MiB / gzip: 1.05 MiB

Would you consider this too large already?