fix: Collection.sortBy() throws on frozen arrays in immutable cache mode - #2294
Conversation
When using immutable cache mode, toArray() returns frozen arrays. Calling .sort() directly on a frozen array throws TypeError. Fix by using .slice().sort() to sort on a copy instead. Fixes #2157
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (1)
📝 WalkthroughWalkthroughUpdated Changes
Estimated code review effort🎯 1 (Trivial) | ⏱️ ~3 minutes Poem
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
Problem
When using
cacheMode: 'immutable',toArray()returns frozen arrays. Calling.sort()directly on a frozen array throws:Fix
Use
.slice().sort()to sort on a copy rather than mutating the original frozen array.Fixes
Fixes #2157
Summary by CodeRabbit