Repository navigation
fix: web 播放器读取环境变量时缺少 process 守卫 - #39
Merged
Merged
Conversation
浏览器构建里没有 process,fetchContributions 直接读 process.env.GITHUB_TOKEN 会抛 ReferenceError。加运行时判断,浏览器侧按无 token 处理并回落到 gh-calendar。
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.
问题
3.4.0 发布后线上 web 播放器报
process is not defined。fetchContributions直接读取process.env.GITHUB_TOKEN,而 web 端的调用链是:web 播放器没有注入
calendarList,因此会执行到该行;浏览器里没有process,直接抛ReferenceError。修复
环境变量读取加运行时守卫,浏览器侧视为无 token,回落到 gh-calendar:
验证
bun biome check .、tsc --noEmit通过bun test:112 pass / 0 failnpm run build:web产物中该表达式已带守卫:typeof process>"u"?void 0:process.env.GITHUB_TOKEN?.trim()dist/已重建