fix: handle undefined manifest value in loadShardedData#799
fix: handle undefined manifest value in loadShardedData#799liuhaibin0528 wants to merge 1 commit into
Conversation
When kv.get() returns undefined for a non-existent key, the strict comparison (manifest.value !== null) evaluates to true, causing undefined to be passed to loadManifestData which crashes with 'Cannot read properties of undefined (reading "v")'. Change to loose comparison (manifest.value != null) to catch both null and undefined, allowing the function to fall through to the legacy data path as intended. Fixes: sharded index crash on old data format
|
@liuhaibin0528 is attempting to deploy a commit to the rohitg00's projects Team on Vercel. A member of the Team first needs to authorize it. |
|
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)
📝 WalkthroughWalkthroughA guard condition in ChangesManifest Value Guard Fix
Estimated code review effort🎯 1 (Trivial) | ⏱️ ~2 minutes Poem
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 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 upgrading from pre-v0.9.25 to v0.9.25, the sharded index loader crashes with:
This happens because
kv.get()returnsundefinedfor keys that don't exist in the old data format, and the strict comparisonmanifest.value !== nullevaluates totruewhenvalue === undefined, causingundefinedto be passed toloadManifestData()which tries to accessundefined.v.Root Cause
In
loadShardedData(src/state/index-persistence.ts:361):kv.get()returnsundefinedfor non-existent keys (notnull), so the strict comparison fails to catch this case.Fix
Change to loose comparison
!= nullwhich catches bothnullandundefined:This allows the function to fall through to the legacy data path as originally intended.
Testing
Summary by CodeRabbit