puzzling waitUntil warning

For the life of me, I'm not sure what part of my code is causing this. The result appears to be a handful of openai calls that are immediately failing, so I'm doing something wrong. I've bundled my async code into a single function which returns via return Promise.all(promises) to ctx.waitUntil() in my fetch. Running it locally (see screenshot) is also indecipherable. tail logs:
"exceptions": [],
"logs": [
{
"message": [
"Missing `waitUntil` option."
],
"level": "warn",
"timestamp": 1723243628284
}
],
"exceptions": [],
"logs": [
{
"message": [
"Missing `waitUntil` option."
],
"level": "warn",
"timestamp": 1723243628284
}
],
index.ts
async fetch(_: FetchEvent, env: Env, ctx: ExecutionContext) {
const scheduledSync = new ScheduledSync(env)
ctx.waitUntil(scheduledSync.sync())
return new Response('ok')
},
async fetch(_: FetchEvent, env: Env, ctx: ExecutionContext) {
const scheduledSync = new ScheduledSync(env)
ctx.waitUntil(scheduledSync.sync())
return new Response('ok')
},
sync.ts (truncated)
export default class ScheduledSync {
private env: Env

constructor(env: Env) {
this.env = env
}

public async sync(): Promise<any> {
let results: any = []
// truncated for clarity:
const users = await g.query<User>('SELECT * FROM echo.dim_users WHERE name iS NOT NULL AND name <> ""') // owners/teammates for this org

results = results.concat(
Promise.all(
users.map((user) => {
// ...
return v.upsert(`user:${user.source_system}:${user.user_id}`, text, meta)
})
)
)
return results
}
}
export default class ScheduledSync {
private env: Env

constructor(env: Env) {
this.env = env
}

public async sync(): Promise<any> {
let results: any = []
// truncated for clarity:
const users = await g.query<User>('SELECT * FROM echo.dim_users WHERE name iS NOT NULL AND name <> ""') // owners/teammates for this org

results = results.concat(
Promise.all(
users.map((user) => {
// ...
return v.upsert(`user:${user.source_system}:${user.user_id}`, text, meta)
})
)
)
return results
}
}
No description
3 Replies
Walshy
Walshyā€¢5mo ago
steyblind
steyblindOPā€¢5mo ago
@Walshy | Deploying DUDE! šŸ†
steyblind
steyblindOPā€¢5mo ago
tossed them a PR to help avoid this in the future. Thanks, folks https://github.com/kriasoft/web-auth-library/pull/29
GitHub
chore(messaging): make waitUntil warning clearer by pkarl Ā· Pull ...
add function name to missing waitUntil warning to improve findability when warning surfaces in cloudflare/miniflare Currently, this warning is surfaced like this when running wrangler dev: ...and...
Want results from more Discord servers?
Add your server