You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I just found out that it works in development environment but it doesn't work as expected when deployed on cloudflare throught nuxthub. event.waitUntil gets blocked and the user waits for the response when it shouldn't happen like that. I tried this and it works:
constwaitFor=(ms: number)=>newPromise((resolve)=>setTimeout(resolve,ms))asyncfunctionbackgroundTask(id: number){awaitwaitFor(5000)console.log(`Task ${id} is done!`)}exportdefaultdefineEventHandler((event)=>{constcfCtx=event.context.cloudflare.contextconsttaskId=Math.round(Math.random()*1000)event.context.taskId=taskIdletnow=newDate()console.log('Time before backgroundTask : '+now.toLocaleTimeString())cfCtx.waitUntil(backgroundTask(taskId))now=newDate()return`Task ${taskId} is running in background... : ${now.toLocaleTimeString()}`})
Additional context
No response
Logs
No response
The text was updated successfully, but these errors were encountered:
@atinux I'm not sure if this is related, but it seems that via NuxtHub this also causes issues with the cached endpoints and functions. I have a cached function with maxAge of 15s. I see the cache entries being created, but they are never updated / removed by Nitro if the mtime or expires date is past due, resulting in always seeing stale data. cc @pi0
Environment
Nuxt 3.12.4 with Nitro 2.9.7 with cloudflare pages preset through nuxthub
Reproduction
https://stackblitz.com/edit/github-ch89s7?file=routes%2Findex.ts,plugins%2Fbackground.ts
Describe the bug
I just found out that it works in development environment but it doesn't work as expected when deployed on cloudflare throught nuxthub. event.waitUntil gets blocked and the user waits for the response when it shouldn't happen like that. I tried this and it works:
Additional context
No response
Logs
No response
The text was updated successfully, but these errors were encountered: