Skip to content

fix(ecosystem): avoid warning when source payload record does not exist - #208

Merged
Gaubee merged 1 commit into
mainfrom
fix/ecosystem-storage-warning
Jan 10, 2026
Merged

Gaubee merged 1 commit into
mainfrom
fix/ecosystem-storage-warning

Conversation

@Gaubee

@Gaubee Gaubee commented Jan 10, 2026

Copy link
Copy Markdown
Contributor

Problem

首页启动时控制台输出多个警告:

[EcosystemStorage] Invalid source payload record: {expected: object, code: invalid_type, path: Array(0), message: Invalid input: expected object, received undefined}

Root Cause

loadSourcePayload 函数在 IndexedDB 记录不存在时(返回 undefined),直接将其传给 Zod schema 验证,导致验证失败并打印警告。

但记录不存在是首次加载时的正常情况,不应该打印警告。

Solution

在 schema 验证前检查 record === undefined,如果不存在则直接返回 null。

Testing

修复前:

=== Console Warnings ===
1. [EcosystemStorage] Invalid source payload record: ...
2. [EcosystemStorage] Invalid source payload record: ...
...
Total: 0 errors, 6 warnings

修复后:

=== Console Errors ===
Total: 0 errors

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.
@Gaubee
Gaubee merged commit 5daa0ef into main Jan 10, 2026
5 checks passed
@Gaubee
Gaubee deleted the fix/ecosystem-storage-warning branch January 10, 2026 16:17
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant