Skip to content

Improve memory footprint of useCanAccess when it targets a record#10828

Merged
Madeorsk merged 2 commits intomasterfrom
use-can-access-record-key
Jul 10, 2025
Merged

Improve memory footprint of useCanAccess when it targets a record#10828
Madeorsk merged 2 commits intomasterfrom
use-can-access-record-key

Conversation

@djhi
Copy link
Copy Markdown
Contributor

@djhi djhi commented Jul 4, 2025

Problem

When wrapping many different records in <CanAccess>, its memory footpring is huge.

Solution

This is because we pass the whole record in the useQuery parameters. We can only pass the record identifier.

How It Was Tested

Before the fix:
image

After the fix:
image

Even with this small use case (records are quite simple), that's 10MB saved.

Additional Checks

  • The PR targets master for a bugfix or a documentation fix, or next for a feature

@djhi djhi added the RFR Ready For Review label Jul 4, 2025
Comment thread packages/ra-core/src/auth/CanAccess.stories.tsx
@Madeorsk Madeorsk self-requested a review July 7, 2025 15:47
Copy link
Copy Markdown
Contributor

@Madeorsk Madeorsk left a comment

Choose a reason for hiding this comment

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

Great! Can you just add the React Query Debugger as @fzaninotto suggested?

@Madeorsk Madeorsk merged commit e883d2c into master Jul 10, 2025
15 checks passed
@Madeorsk Madeorsk deleted the use-can-access-record-key branch July 10, 2025 10:26
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

RFR Ready For Review

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants