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

Race condition on generateEndPoints function #18

Closed
anonrig opened this issue Feb 4, 2020 · 1 comment
Closed

Race condition on generateEndPoints function #18

anonrig opened this issue Feb 4, 2020 · 1 comment

Comments

@anonrig
Copy link
Collaborator

anonrig commented Feb 4, 2020

By default we're using lodash each function to iterate over actions of the endpoints and using async function as a callback, to run promises inside this.

When iterating through node inspect mode, I couldn't find any issue but, when running through an actual npm start I've received the following error:

By default lodash each iteraction doesn't wait for callback function async to finish and may cause inconsistencies like the following:

https://github.com/iyobo/koa-ts-controllers/blob/master/src/util/generateRoutes.ts#L94

(node:84929) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). (rejection id: 24)
(node:84929) UnhandledPromiseRejectionWarning: TypeError: undefined is not a function
    at /Users/yagiz/Workspace/alfred/node_modules/koa-ts-controllers/dist/util/generateRoutes.js:110:32
    at /Users/yagiz/Workspace/alfred/node_modules/lodash/lodash.js:4905:15
    at baseForOwn (/Users/yagiz/Workspace/alfred/node_modules/lodash/lodash.js:2990:24)
    at /Users/yagiz/Workspace/alfred/node_modules/lodash/lodash.js:4874:18
    at Function.forEach (/Users/yagiz/Workspace/alfred/node_modules/lodash/lodash.js:9342:14)
    at _generateEndPoints (/Users/yagiz/Workspace/alfred/node_modules/koa-ts-controllers/dist/util/generateRoutes.js:80:22)
    at /Users/yagiz/Workspace/alfred/node_modules/koa-ts-controllers/dist/util/generateRoutes.js:143:19
    at /Users/yagiz/Workspace/alfred/node_modules/lodash/lodash.js:4905:15
    at baseForOwn (/Users/yagiz/Workspace/alfred/node_modules/lodash/lodash.js:2990:24)
    at /Users/yagiz/Workspace/alfred/node_modules/lodash/lodash.js:4874:18
    at Function.forEach (/Users/yagiz/Workspace/alfred/node_modules/lodash/lodash.js:9342:14)
    at Object.generateRoutes (/Users/yagiz/Workspace/alfred/node_modules/koa-ts-controllers/dist/util/generateRoutes.js:140:22)
    at Object.exports.bootstrapControllers (/Users/yagiz/Workspac
anonrig added a commit to anonrig/koa-ts-controllers that referenced this issue Feb 4, 2020
@iyobo
Copy link
Owner

iyobo commented Feb 5, 2020

Resolved and deployed in v1.5

@iyobo iyobo closed this as completed Feb 5, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants