-
Notifications
You must be signed in to change notification settings - Fork 2.1k
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
IN-4121 - async hooks / api client #7155
base: main
Are you sure you want to change the base?
Conversation
|
} | ||
|
||
next(); | ||
getApiFunction(apiClientInstance, functionName, extensionName) |
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.
nit pick but I'd like to have async/await syntax in here as well (easier debugging imho), but you'd need to use this lib: https://www.npmjs.com/package/express-async-handler
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.
Can you make onCreate
async in packages/middleware/__tests__/integration/bootstrap/server.ts
to validate async behaviour?
# Conflicts: # packages/middleware/src/apiClientFactory/index.ts # packages/middleware/src/handlers/prepareApiFunction/getApiFunction.ts # packages/middleware/src/handlers/prepareApiFunction/index.ts
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.
Still, missing the integration tests to validate full scenario with extensions.
): (req, res, next) => Promise<any> { | ||
return async (req, res, next) => { |
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.
I don't like this hack in here ;p I'd go with https://www.npmjs.com/package/express-async-handler and avoid defining the return type, then express will validate if it returns what's expected.
): (req, res, next) => Promise<any> { | |
return async (req, res, next) => { | |
) { | |
return asyncHandler(async (req, res, next) => { ... }); |
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.
You could also try without the lib and without the Promise in return type
); | ||
.reduce(async (configSoFar, extension) => { | ||
const resolvedConfig = await configSoFar; | ||
return extension.beforeCreate({ configuration: resolvedConfig }); |
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.
await on lifecycles seems fine but I think you missed async behaviour on hooks like beforeCreate
, afterCreate
, beforeCall
and afterCall
π Linked issue
β Type of change
π Description
π Checklist