-
Notifications
You must be signed in to change notification settings - Fork 204
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Feature: getMiniflareWaitUntil #345
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hey! 👋 Thanks for the PR! I've added some suggestions. I think we should implicitly Promise.all()
for users, since they're very likely to do this themselves anyway.
global.getMiniflareWaitUntil = ( | ||
event: FetchEvent | ScheduledEvent | ||
): Promise<unknown>[] => { | ||
return event[kWaitUntil]; | ||
}; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
With the above change, you could replace this with a reference to the getWaitUntil
function.
} | ||
|
||
flush<WaitUntil extends any[] = unknown[]>(): Promise<WaitUntil> { | ||
return Promise.all(this[kWaitUntil]) as Promise<WaitUntil>; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Apologies, I might be doing this wrong, but I get an error if I don't explain that any doesn't fall outside unknown.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hey! 👋 Added a couple more comments, but otherwise, looks good. 🙂
00a9466
to
2048eff
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
One tiny thing, then I'll merge! ✅
Co-authored-by: CraigglesO <oconnorct1@gmail.com>
098beb9
to
587656a
Compare
Hey! 👋 I'm aiming to get a release out today and want to include this. I realised my changes with |
My fault for not finishing. Got really busy this week again. Just happy to see this go through! |
Resolves #202
Adds
getMiniflareWaitUntil(event: FetchEvent | ScheduledEvent): Promise<unknown>[];
to return an array of promises stored viaevent.waitUntill(...)
Example usage for both
FetchEvent
andScheduledEvent
can be found atpackages/jest-environment-miniflare/test/fixtures/waitUntil.worker.spec.js