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

fix: allow for synchronous building of file requests #211

Merged
merged 1 commit into from
Oct 21, 2022

Conversation

dpopp07
Copy link
Member

@dpopp07 dpopp07 commented Oct 21, 2022

This issue was caused by an oversight in adding an await statement within a forEach loop, which will result in asynchronous operations happening without the synchronous control you'd expect from async/await.

This solves the issue by simply converting the loops to "for of" loops.

This caused a subtle server error so unfortunately, I can't think of a great test case for it. I should've known not to put an await call within a forEach though. Logically, this is a simple refactor, but practically it makes the code behave in the way it was actually intended to.

cc @apaparazzi0329

@dpopp07 dpopp07 requested a review from padamstx October 21, 2022 18:10
@dpopp07
Copy link
Member Author

dpopp07 commented Oct 21, 2022

Seeing some linting failures (related to async/await within loops, ironically). I'll get those sorted

Copy link
Member

@padamstx padamstx left a comment

Choose a reason for hiding this comment

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

Looks good except for the build failures :)

This issue was caused by an oversight in adding an `await` statement within a `forEach`
loop, which will result in asynchronous operations happening without the synchronous
control you'd expect from async/await.

This solves the issue by simply converting the loops to "for of" loops.

Note that the AirBnb style guide we follow prohibits the use of "for of" loops and that
ESLint discourages "await" statements in any kind of loop. However, to adherence to the
rules would require a significant refactor that is not current worth the effort. So for
now, we are ignoring the rules.

Signed-off-by: Dustin Popp <dpopp07@gmail.com>
@dpopp07 dpopp07 merged commit dcce4ea into main Oct 21, 2022
@dpopp07 dpopp07 deleted the dp/file-request-bug branch October 21, 2022 20:20
ibm-devx-sdk pushed a commit that referenced this pull request Oct 21, 2022
## [3.2.1](v3.2.0...v3.2.1) (2022-10-21)

### Bug Fixes

* allow for synchronous building of file requests ([#211](#211)) ([dcce4ea](dcce4ea))
@ibm-devx-sdk
Copy link

🎉 This PR is included in version 3.2.1 🎉

The release is available on:

Your semantic-release bot 📦🚀

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants