-
Notifications
You must be signed in to change notification settings - Fork 2.9k
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
[No QA] Check for undefined in promiseWhile.ts #39830
[No QA] Check for undefined in promiseWhile.ts #39830
Conversation
@@ -30,6 +30,11 @@ function promiseDoWhile(condition: () => boolean, action: (() => Promise<void>) | |||
console.info('[promiseWhile] promiseDoWhile() condition', condition); | |||
const actionResult = action?.(); | |||
console.info('[promiseWhile] promiseDoWhile() actionResult', actionResult); | |||
|
|||
if (actionResult === undefined) { | |||
resolve(); |
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.
Wow, great find @JKobrynski. I'm only curious if we should resolve
or reject
here?
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.
Great question, I'm going to ask for some opinions
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.
A slight adjustment:
function promiseDoWhile(condition: () => boolean, action: (() => Promise<void>) | DebouncedFunc<() => Promise<void>> | undefined): Promise<void> {
console.info('[promiseWhile] promiseDoWhile()');
return new Promise((resolve, reject) => {
console.info('[promiseWhile] promiseDoWhile() condition', condition);
const actionResult = action?.();
console.info('[promiseWhile] promiseDoWhile() actionResult', actionResult);
if (!actionResult) {
resolve();
return;
}
actionResult
.then(() => promiseWhile(condition, action))
.then(resolve)
.catch(reject);
});
}
@cubuspl42 Please copy/paste the Reviewer Checklist from here into a new comment on this PR and complete it. If you have the K2 extension, you can simply click: [this button] |
Reviewer Checklist
Screenshots/VideosAndroid: NativeAndroid: mWeb ChromeiOS: NativeiOS: mWeb SafariMacOS: Chrome / SafariMacOS: Desktop |
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.
Thanks for digging into this, it looks good to me
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.
Finger crossed it fixes it! 🤞
✋ This PR was not deployed to staging yet because QA is ongoing. It will be automatically deployed to staging after the next production release. |
🚀 Deployed to staging by https://github.com/mountiny in version: 1.4.62-0 🚀
|
1 similar comment
🚀 Deployed to staging by https://github.com/mountiny in version: 1.4.62-0 🚀
|
🚀 Deployed to staging by https://github.com/mountiny in version: 1.4.62-0 🚀
|
🚀 Deployed to production by https://github.com/thienlnam in version: 1.4.62-17 🚀
|
Details
To get the whole context of the bug check the latest logs.
I think the most likely cause of that promise loop is
actionResult
(promiseWhile.ts) beingundefined
(you can see all manyPromise<undefined>
in the logs). The function takes that result and tries to perform the following actions on it:Which can't be done, as it's
undefined
but there are no checks for it, so the function gets stuck.Optional chaining for this procedure was introduced in this PR. And here is a little demo of what difference it makes (S/O @blazejkustra)
My suggestion would be to add a simple check for
undefined
before trying to chain it and seeing if it solves our issue.Fixed Issues
$ #39066
PROPOSAL: N/A
Tests
Offline tests
QA Steps
PR Author Checklist
### Fixed Issues
section aboveTests
sectionOffline steps
sectionQA steps
sectiontoggleReport
and notonIconClick
)myBool && <MyComponent />
.src/languages/*
files and using the translation methodSTYLE.md
) were followedAvatar
, I verified the components usingAvatar
are working as expected)StyleUtils.getBackgroundAndBorderStyle(theme.componentBG)
)Avatar
is modified, I verified thatAvatar
is working as expected in all cases)Design
label and/or tagged@Expensify/design
so the design team can review the changes.ScrollView
component to make it scrollable when more elements are added to the page.main
branch was merged into this PR after a review, I tested again and verified the outcome was still expected according to theTest
steps.