-
Notifications
You must be signed in to change notification settings - Fork 916
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
[Workspace]Fix maximum call stack error in use case service #7817
[Workspace]Fix maximum call stack error in use case service #7817
Conversation
Signed-off-by: Lin Wang <wonglam@amazon.com>
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## main #7817 +/- ##
=======================================
Coverage 63.82% 63.83%
=======================================
Files 3658 3658
Lines 81286 81288 +2
Branches 12975 12974 -1
=======================================
+ Hits 51884 51888 +4
+ Misses 26217 26216 -1
+ Partials 3185 3184 -1
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. |
Signed-off-by: Lin Wang <wonglam@amazon.com>
const compareFeatures = ( | ||
features1: WorkspaceUseCaseFeature[], | ||
features2: WorkspaceUseCaseFeature[] | ||
) => { | ||
const featureSerialize = ({ id, title }: WorkspaceUseCaseFeature) => `${id}-${title}`; | ||
const features1Set = new Set(features1.map(featureSerialize)); | ||
const features2Set = new Set(features2.map(featureSerialize)); | ||
if (features1Set.size !== features2Set.size) { | ||
return false; | ||
} | ||
for (const feature of features1Set) { | ||
if (!features2Set.has(feature)) { | ||
return false; | ||
} | ||
} | ||
return true; | ||
}; | ||
|
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.
Perhaps we can simplify the compare by sorting the serialized array and see if JSON.stringify(sortArray) equals?
Signed-off-by: Lin Wang <wonglam@amazon.com>
Signed-off-by: Lin Wang <wonglam@amazon.com>
Signed-off-by: Lin Wang <wonglam@amazon.com>
The backport to
To backport manually, run these commands in your terminal: # Navigate to the root of your repository
cd $(git rev-parse --show-toplevel)
# Fetch latest updates from GitHub
git fetch
# Create a new working tree
git worktree add ../.worktrees/OpenSearch-Dashboards/backport-2.x 2.x
# Navigate to the new working tree
pushd ../.worktrees/OpenSearch-Dashboards/backport-2.x
# Create a new branch
git switch --create backport/backport-7817-to-2.x
# Cherry-pick the merged commit of this pull request and resolve the conflicts
git cherry-pick -x --mainline 1 452b65dceff7c9a2f283f0dda0793d0a4a8f3aba
# Push it to GitHub
git push --set-upstream origin backport/backport-7817-to-2.x
# Go back to the original working tree
popd
# Delete the working tree
git worktree remove ../.worktrees/OpenSearch-Dashboards/backport-2.x Then, create a pull request where the |
* Fix maximum call stack error in UseCaseService Signed-off-by: Lin Wang <wonglam@amazon.com> * Changeset file for PR #7817 created/updated * Improve UT coverage Signed-off-by: Lin Wang <wonglam@amazon.com> * Refactor compare with sort Signed-off-by: Lin Wang <wonglam@amazon.com> * Refactor compareFeatures Signed-off-by: Lin Wang <wonglam@amazon.com> * Add ut for multi same features Signed-off-by: Lin Wang <wonglam@amazon.com> --------- Signed-off-by: Lin Wang <wonglam@amazon.com> Co-authored-by: opensearch-changeset-bot[bot] <154024398+opensearch-changeset-bot[bot]@users.noreply.github.com> (cherry picked from commit 452b65d) Signed-off-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
…7840) * Fix maximum call stack error in UseCaseService * Changeset file for PR #7817 created/updated * Improve UT coverage * Refactor compare with sort * Refactor compareFeatures * Add ut for multi same features --------- (cherry picked from commit 452b65d) Signed-off-by: Lin Wang <wonglam@amazon.com> Signed-off-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com> Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com> Co-authored-by: opensearch-changeset-bot[bot] <154024398+opensearch-changeset-bot[bot]@users.noreply.github.com>
Description
This PR is for fixing maximum call stack error in use case service, separate a function to compare features using
sort
instead of usingArray.property.some
.The root cause of this bug should be error features compare result see below example:
The result should be
true
which means two use case should be equal. But the old compare logic will returnfalse
. We should changeb.features.some
tob.features.every
, then the result would be correct. Usingsome
andevery
to implement the compare logic would be a little bit complicated, it can't handle duplicate features. So we change to usesort
to compare the use case.Issues Resolved
#7820
Screenshot
No UI changes
Testing the changes
yarn osd bootstrap --single-version ignore
config/opensearch_dashboards.yml
yarn start --no-base-path
Maximum call stack error
in the consoleChangelog
Check List
yarn test:jest
yarn test:jest_integration