[No QA] Check for undefined in promiseWhile.ts#39830
[No QA] Check for undefined in promiseWhile.ts#39830mountiny merged 2 commits intoExpensify:mainfrom
Conversation
| console.info('[promiseWhile] promiseDoWhile() actionResult', actionResult); | ||
|
|
||
| if (actionResult === undefined) { | ||
| resolve(); |
There was a problem hiding this comment.
Wow, great find @JKobrynski. I'm only curious if we should resolve or reject here?
There was a problem hiding this comment.
Great question, I'm going to ask for some opinions
There was a problem hiding this comment.
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 |
mountiny
left a comment
There was a problem hiding this comment.
Thanks for digging into this, it looks good to me
blazejkustra
left a comment
There was a problem hiding this comment.
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
undefinedbut 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
undefinedbefore 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 Issuessection aboveTestssectionOffline stepssectionQA stepssectiontoggleReportand notonIconClick)myBool && <MyComponent />.src/languages/*files and using the translation methodSTYLE.md) were followedAvatar, I verified the components usingAvatarare working as expected)StyleUtils.getBackgroundAndBorderStyle(theme.componentBG))Avataris modified, I verified thatAvataris working as expected in all cases)Designlabel and/or tagged@Expensify/designso the design team can review the changes.ScrollViewcomponent to make it scrollable when more elements are added to the page.mainbranch was merged into this PR after a review, I tested again and verified the outcome was still expected according to theTeststeps.