Repository navigation
fix: graceful fallback when statsig client is not initialized - #10
Closed
xingxinglieo wants to merge 6 commits into
Closed
xingxinglieo wants to merge 6 commits into
xingxinglieo wants to merge 6 commits into
Conversation
- Add build script with tsc - Update exports to point to dist/ - Add prepublishOnly hook - Set type: module for ESM output Co-authored-by: Cursor <cursoragent@cursor.com>
ts-node with commonjs module cannot resolve subpath exports without a default fallback condition. Co-authored-by: Cursor <cursoragent@cursor.com>
lodash is CJS-only and breaks named imports in ESM context. Co-authored-by: Cursor <cursoragent@cursor.com>
FlagStore.resolve() and ParamStore.resolve() now catch the getStatsigClientSync() throw and return fallback values instead of crashing, preventing module-level side-effects from blowing up when the entry point has not called initStatsigClient() yet. Co-authored-by: Cursor <cursoragent@cursor.com>
|
📦 Canary version published! pnpm add statsig@0.0.3-canary.pr10.fd78749
# or
pnpm add statsig@canary |
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.
Summary
FlagStore.resolve()和ParamStore.resolve()在第4步获取远端值时,对getStatsigClientSync()加 try-catch 防御client.ts错误消息中的包名Background
在 monorepo 的
canvas/agent-share独立入口中,模块级别的new AgentSocket()在 import 求值阶段调用了flagStore.getFlag('dm'),但此时initStatsigClient()尚未被调用,导致getStatsigClientSync()抛出Not initialized异常,页面崩溃。根因是
FlagStore.resolve()和ParamStore.resolve()没有对 statsig 未初始化的场景做防御处理。Test plan
pnpm typecheck通过pnpm test全部 21 个测试通过/r/分享页不再崩溃Made with Cursor