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: maximum call stack size #4674

Merged
merged 4 commits into from
Oct 18, 2024
Merged

fix: maximum call stack size #4674

merged 4 commits into from
Oct 18, 2024

Conversation

vince292007
Copy link
Collaborator

@vince292007 vince292007 commented Oct 18, 2024

Description

fixed #4672

Type of change

Please delete options that are not relevant.

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • This change requires a documentation update
  • Please, don't make changes to pnpm-lock.yaml unless you introduce a new test example.

Checklist

ℹ️ Check all checkboxes - this will indicate that you have done everything in accordance with the rules in CONTRIBUTING.

  • If you introduce new functionality, document it. You can run documentation with pnpm run docs:dev command.
  • Run the tests with pnpm test.
  • Changes in changelog are generated from PR name. Please, make sure that it explains your changes in an understandable manner. Please, prefix changeset messages with feat:, fix:, perf:, docs:, or chore:.
  • My code follows the style guidelines of this project
  • I have performed a self-review of my own code
  • I have commented my code, particularly in hard-to-understand areas
  • I have made corresponding changes to the documentation
  • My changes generate no new warnings
  • I have added tests that prove my fix is effective or that my feature works
  • New and existing unit tests pass locally with my changes
  • Any dependent changes have been merged and published in downstream modules

Summary by CodeRabbit

  • New Features

    • Updated version to 5.4.0 for the shared package.
    • Enhanced tab components with a new property name in the tab configuration.
  • Bug Fixes

    • Removed the deprecated deepToRaw utility, simplifying tab object handling.
  • Refactor

    • Restructured the exports for better organization.
    • Updated menu item processing in the layout component to use cloneDeep instead of deepToRaw.
    • Simplified the mapping logic in the tabsView computed property across tab components.
    • Streamlined the handling of tab properties in the tabsView computed property.

@vince292007 vince292007 added the bug Something isn't working label Oct 18, 2024
@vince292007 vince292007 requested a review from anncwb as a code owner October 18, 2024 05:47
Copy link

changeset-bot bot commented Oct 18, 2024

⚠️ No Changeset found

Latest commit: e2dccdf

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

This PR includes no changesets

When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

Click here to learn what changesets are, and how to add one.

Click here if you're a maintainer who wants to add a changeset to this PR

Copy link
Contributor

coderabbitai bot commented Oct 18, 2024

Walkthrough

The pull request introduces several changes primarily to the @vben-core/shared package, including an update to version 5.4.0, restructuring of the exports section to point to .d.ts files, and the removal of the @vue/reactivity dependency. Additionally, the deepToRaw utility function has been removed, affecting various components that previously relied on it, such as tabs.vue and layout.vue. The changes simplify how tab configurations and menu items are processed.

Changes

File Path Change Summary
packages/@core/base/shared/package.json Version updated to 5.4.0; exports paths updated to .d.ts files; removed @vue/reactivity dependency.
packages/@core/base/shared/src/utils/index.ts Removed export statement for ./reactivity.
packages/@core/base/shared/src/utils/reactivity.ts Removed file containing deepToRaw function.
packages/@core/ui-kit/tabs-ui/src/components/tabs-chrome/tabs.vue Simplified tabsView computed property; removed deepToRaw utility; added name property to returned object.
packages/@core/ui-kit/tabs-ui/src/components/tabs/tabs.vue Removed import of TabConfig; simplified tabsView computed property.
packages/effects/layouts/src/basic/layout.vue Replaced deepToRaw with cloneDeep in wrapperMenus function.

Assessment against linked issues

Objective Addressed Explanation
Remove deepToRaw to resolve RangeError in build (4672)
Ensure tabs display correctly after login (4672)

Possibly related PRs

Poem

🐰 In the meadow, changes bloom,
The deepToRaw has met its doom.
Tabs now dance with names so bright,
A simpler path brings pure delight.
With every hop, the code takes flight! 🌼


📜 Recent review details

Configuration used: CodeRabbit UI
Review profile: CHILL

📥 Commits

Files that changed from the base of the PR and between 186c588 and e2dccdf.

📒 Files selected for processing (2)
  • packages/@core/ui-kit/tabs-ui/src/components/tabs-chrome/tabs.vue (1 hunks)
  • packages/@core/ui-kit/tabs-ui/src/components/tabs/tabs.vue (1 hunks)
🚧 Files skipped from review as they are similar to previous changes (2)
  • packages/@core/ui-kit/tabs-ui/src/components/tabs-chrome/tabs.vue
  • packages/@core/ui-kit/tabs-ui/src/components/tabs/tabs.vue

Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media?

❤️ Share
🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Generate unit testing code for this file.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai generate unit testing code for this file.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and generate unit testing code.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 1

🧹 Outside diff range and nitpick comments (3)
packages/@core/ui-kit/tabs-ui/src/components/tabs/tabs.vue (1)

48-60: LGTM! Consider adding type annotation and unit tests.

The changes to the tabsView computed property align with the PR objective to fix the "Maximum call stack size exceeded" error. The removal of deepToRaw and simplification of the mapping function should improve performance and reduce the risk of stack overflow.

However, consider the following suggestions:

  1. Add a type annotation to the tabsView computed property to maintain type safety:
const tabsView = computed((): { affixTab: boolean; closable: boolean; icon: string; key: string; name: string; title: string }[] => {
  // ... existing code ...
});
  1. To ensure the changes don't introduce new bugs, it would be beneficial to add or update unit tests for this component.

Would you like assistance in generating unit tests for the tabsView computed property?

packages/@core/ui-kit/tabs-ui/src/components/tabs-chrome/tabs.vue (1)

43-51: LGTM! Consider adding type annotation for improved safety.

The changes to the tabsView computed property look good. The removal of deepToRaw simplifies the code and potentially improves performance. The addition of the name property provides more flexibility in tab handling.

These changes align well with the PR objective of fixing the "Maximum call stack size exceeded" error by simplifying object handling.

For improved type safety, consider adding a type annotation to the map function:

- return props.tabs.map((tab) => {
+ return props.tabs.map((tab): TabConfig => {

This ensures that the returned object strictly adheres to the TabConfig interface.

packages/effects/layouts/src/basic/layout.vue (1)

115-115: Approve the use of cloneDeep in wrapperMenus function.

The change from deepToRaw to cloneDeep in the wrapperMenus function is consistent with the import statement modification and should help prevent the stack overflow issue.

Consider this minor optimization to avoid unnecessary deep cloning of primitive values:

-    return { ...cloneDeep(item), name: $t(item.name) };
+    const clonedItem = cloneDeep(item);
+    clonedItem.name = $t(item.name);
+    return clonedItem;

This change ensures that we're not unnecessarily cloning the already translated name property.

📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

📥 Commits

Files that changed from the base of the PR and between 6cd9937 and b7ded1d.

⛔ Files ignored due to path filters (1)
  • pnpm-lock.yaml is excluded by !**/pnpm-lock.yaml
📒 Files selected for processing (6)
  • packages/@core/base/shared/package.json (0 hunks)
  • packages/@core/base/shared/src/utils/index.ts (0 hunks)
  • packages/@core/base/shared/src/utils/reactivity.ts (0 hunks)
  • packages/@core/ui-kit/tabs-ui/src/components/tabs-chrome/tabs.vue (1 hunks)
  • packages/@core/ui-kit/tabs-ui/src/components/tabs/tabs.vue (2 hunks)
  • packages/effects/layouts/src/basic/layout.vue (2 hunks)
💤 Files with no reviewable changes (3)
  • packages/@core/base/shared/package.json
  • packages/@core/base/shared/src/utils/index.ts
  • packages/@core/base/shared/src/utils/reactivity.ts
🧰 Additional context used
🔇 Additional comments (3)
packages/@core/ui-kit/tabs-ui/src/components/tabs/tabs.vue (1)

Line range hint 1-138: Summary: Changes address the reported issue and improve code quality.

The modifications in this file effectively address the "Maximum call stack size exceeded" error by removing the deepToRaw function and simplifying the tab processing logic. The changes align well with the PR objectives and should resolve the reported issue.

Key improvements:

  1. Removal of unnecessary TabConfig import and usage.
  2. Simplification of the tabsView computed property.
  3. Addition of the name property to tab objects.

These changes should improve performance and reduce the risk of stack overflow errors. The code quality has been enhanced through simplification, although adding a type annotation to tabsView would further improve type safety.

Overall, the changes look good and achieve the intended goals of the PR.

packages/effects/layouts/src/basic/layout.vue (2)

Line range hint 1-385: Summary of changes and expected impact.

The modifications in this file are focused on addressing the "Maximum call stack size exceeded" error mentioned in the PR objectives. The primary changes involve:

  1. Replacing deepToRaw with cloneDeep in the import statement.
  2. Updating the wrapperMenus function to use cloneDeep instead of deepToRaw.

These changes should resolve the stack overflow issue while maintaining the original functionality of the component. The rest of the file remains unchanged, which minimizes the risk of introducing new bugs.

To ensure the changes have the intended effect:

  1. Verify that the "Maximum call stack size exceeded" error no longer occurs after building the project.
  2. Test the application's behavior when logging in and out, particularly focusing on the display of small tabs.
  3. Conduct thorough testing of menu-related functionality to ensure no regressions have been introduced.

Run the following script to check for any potential issues related to the changes:

✅ Verification successful

Verification Successful

All checks have passed:

  • No remaining uses of deepToRaw in the codebase.
  • cloneDeep is correctly imported from @vben/utils.
  • No circular dependencies detected that could cause stack overflow.

These changes effectively address the "Maximum call stack size exceeded" error without introducing new issues.

🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Verify the impact of changes on menu-related functionality

# Test: Check for any remaining uses of deepToRaw in menu-related files
rg --type vue --type ts --type js 'deepToRaw' packages/effects/layouts/src/

# Test: Verify that cloneDeep is properly imported in menu-related files
rg --type vue --type ts --type js 'import.*cloneDeep.*from.*@vben/utils' packages/effects/layouts/src/

# Test: Look for any potential circular dependencies that might still cause stack overflow
rg --type vue --type ts --type js 'import.*from.*@vben/utils.*\nimport.*from.*@vben/utils' packages/effects/layouts/src/

Length of output: 551


Script:

#!/bin/bash
# Description: Verify the impact of changes on menu-related functionality

# Test: Check for any remaining uses of deepToRaw in menu-related files
rg 'deepToRaw' packages/effects/layouts/src/ --glob '*.vue' --glob '*.ts' --glob '*.js'

# Test: Verify that cloneDeep is properly imported in menu-related files
rg 'import\s+.*cloneDeep.*from\s+["@]vben/utils["]' packages/effects/layouts/src/ --glob '*.vue' --glob '*.ts' --glob '*.js'

# Test: Look for any potential circular dependencies that might still cause stack overflow
rg 'import\s+.*from\s+["@]vben/utils["]' packages/effects/layouts/src/ --glob '*.vue' --glob '*.ts' --glob '*.js' --multiline

Length of output: 342


14-14: Approve the replacement of deepToRaw with cloneDeep.

This change from deepToRaw to cloneDeep is likely to resolve the "Maximum call stack size exceeded" error mentioned in the PR objectives. The cloneDeep function is generally more robust when dealing with complex or circular data structures, which could have been causing the stack overflow issue.

To ensure this change doesn't introduce any new issues, please run the following verification script:

✅ Verification successful

Replacement of deepToRaw with cloneDeep verified successfully. No remaining instances of deepToRaw found.

🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Check for any remaining uses of deepToRaw in the codebase

# Test: Search for any remaining uses of deepToRaw
rg --type vue --type ts --type js 'deepToRaw'

# Test: Verify that cloneDeep is imported from @vben/utils in other files
rg --type vue --type ts --type js 'import.*cloneDeep.*from.*@vben/utils'

Length of output: 176


Script:

#!/bin/bash
# Description: Check for any remaining uses of deepToRaw in the codebase

# Test: Search for any remaining uses of deepToRaw in .vue, .ts, and .js files
rg 'deepToRaw' --glob='*.vue' --glob='*.ts' --glob='*.js'

# Test: Verify that cloneDeep is imported from @vben/utils in .vue, .ts, and .js files
rg 'import\s+.*cloneDeep.*from\s+["\']@vben/utils["\']' --glob='*.vue' --glob='*.ts' --glob='*.js'

Length of output: 151


Script:

#!/bin/bash
# Description: Check for any remaining uses of deepToRaw in the codebase

# Test: Search for any remaining uses of deepToRaw in .vue, .ts, and .js files
rg "deepToRaw" --glob "*.vue" --glob "*.ts" --glob "*.js"

# Test: Verify that cloneDeep is imported from @vben/utils in .vue, .ts, and .js files
rg "import\s+.*cloneDeep.*from\s+['\"]@vben/utils['\"]" --glob "*.vue" --glob "*.ts" --glob "*.js"

Length of output: 383

packages/@core/ui-kit/tabs-ui/src/components/tabs/tabs.vue Outdated Show resolved Hide resolved
@vince292007 vince292007 merged commit c491b9e into main Oct 18, 2024
14 checks passed
@vince292007 vince292007 deleted the issue-4672 branch October 18, 2024 06:24
GavinLucky pushed a commit to GavinLucky/vue-vben-admin that referenced this pull request Oct 23, 2024
* fix: maximum call stack size
@github-actions github-actions bot locked and limited conversation to collaborators Nov 18, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
bug Something isn't working
Projects
None yet
1 participant