Skip to content
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

feat(bot): add support for Prefer: respond-async on Bot/$execute #4461

Merged
merged 5 commits into from
Apr 29, 2024

Conversation

ThatOneBro
Copy link
Member

@ThatOneBro ThatOneBro commented Apr 26, 2024

Depends on #4455

Closes #4458

@ThatOneBro ThatOneBro requested a review from a team as a code owner April 26, 2024 17:25
Copy link

vercel bot commented Apr 26, 2024

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
medplum-provider ✅ Ready (Inspect) Visit Preview 💬 Add feedback Apr 29, 2024 6:32pm
3 Ignored Deployments
Name Status Preview Comments Updated (UTC)
medplum-app ⬜️ Ignored (Inspect) Visit Preview Apr 29, 2024 6:32pm
medplum-storybook ⬜️ Ignored (Inspect) Visit Preview Apr 29, 2024 6:32pm
medplum-www ⬜️ Ignored (Inspect) Visit Preview Apr 29, 2024 6:32pm

@@ -76,11 +83,51 @@ export interface BotExecutionResult {
* Assumes that input content-type is output content-type.
*/
export const executeHandler = asyncWrap(async (req: Request, res: Response) => {
if (req.header('Prefer') === 'respond-async') {
await sendAsyncResponse(req, res, async () => {
return new Promise<Parameters>((resolve, reject) => {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Any reason not to make this async?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I believe this was the only way to make the outer promise resolve after the execution of the inner callback... could be a way to refactor it to an async function but it's not obvious to me at the moment

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actually I was wrong there was a pretty clear refactor making executeOperation return what was getting passed through the callback and turning everything async

@ThatOneBro ThatOneBro force-pushed the derrick-bot-execute-prefer-async branch from 0f98f14 to 330d207 Compare April 29, 2024 18:09
Copy link

sonarcloud bot commented Apr 29, 2024

@ThatOneBro ThatOneBro added this pull request to the merge queue Apr 29, 2024
Merged via the queue into main with commit b0a1d7c Apr 29, 2024
32 checks passed
@ThatOneBro ThatOneBro deleted the derrick-bot-execute-prefer-async branch April 29, 2024 18:41
medplumbot added a commit that referenced this pull request Apr 29, 2024
Add projectId to batch metrics (#4454)Removing duplicate content fixes #4390 (#4431)
feat(agent): support `Prefer: respond-async` for `Agent/$push` (#4455)
Update default project access policy for new systemSetting (#4466)
Fixes #4463 - remove version history circuit breaker (#4467)
[Provider app] Add patient communications tab (#4465)
feat(bot): add support for `Prefer: respond-async` on `Bot/$execute` (#4461)
Split minor and major version upgrades (#4475)
Dependency upgrades 2024-04-29 (#4472)
Add Extension to Bot resource (#4474)
Fix tar.x import (#4477)
codyebberson pushed a commit that referenced this pull request Apr 30, 2024
Add projectId to batch metrics (#4454)Removing duplicate content fixes #4390 (#4431)
feat(agent): support `Prefer: respond-async` for `Agent/$push` (#4455)
Update default project access policy for new systemSetting (#4466)
Fixes #4463 - remove version history circuit breaker (#4467)
[Provider app] Add patient communications tab (#4465)
feat(bot): add support for `Prefer: respond-async` on `Bot/$execute` (#4461)
Split minor and major version upgrades (#4475)
Dependency upgrades 2024-04-29 (#4472)
Add Extension to Bot resource (#4474)
Fix tar.x import (#4477)
github-merge-queue bot pushed a commit that referenced this pull request Apr 30, 2024
Add projectId to batch metrics (#4454)Removing duplicate content fixes #4390 (#4431)
feat(agent): support `Prefer: respond-async` for `Agent/$push` (#4455)
Update default project access policy for new systemSetting (#4466)
Fixes #4463 - remove version history circuit breaker (#4467)
[Provider app] Add patient communications tab (#4465)
feat(bot): add support for `Prefer: respond-async` on `Bot/$execute` (#4461)
Split minor and major version upgrades (#4475)
Dependency upgrades 2024-04-29 (#4472)
Add Extension to Bot resource (#4474)
Fix tar.x import (#4477)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bots Features and fixes related to bots and automation
Projects
Status: ✅ Done
Development

Successfully merging this pull request may close these issues.

Support Prefer-async for Bot/$execute
2 participants