Repository navigation
fix(ecosystem): avoid warning when source payload record does not exist - #208
Merged
Merged
Conversation
The loadSourcePayload function was logging a warning when the record was undefined (not found in IndexedDB), which is a normal case on first load. Now we check for undefined before schema validation.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
首页启动时控制台输出多个警告:
Root Cause
loadSourcePayload函数在 IndexedDB 记录不存在时(返回undefined),直接将其传给 Zod schema 验证,导致验证失败并打印警告。但记录不存在是首次加载时的正常情况,不应该打印警告。
Solution
在 schema 验证前检查
record === undefined,如果不存在则直接返回null。Testing
修复前:
修复后: