修复个人微信前端在 headless 容器内无法登录#595
Open
Michaelxwb wants to merge 5 commits into
Open
Conversation
容器化部署时个人微信前端无法首次扫码登录,定位并修复 4 处问题: 1. isatty 闸门顺序错误:__main__ 先把 stdout 重定向到日志文件,再判 sys.stdout.isatty()——文件句柄恒为 false,导致无 token 时必然退出。 改为始终走 QR 登录、二维码打到真实 stdout(docker logs 可见), 无需 TTY 即可扫码。 2. get_bot_qrcode 无容错:被限流时响应缺 'qrcode' 字段直接 KeyError 崩溃, 配合 restart 策略形成死亡螺旋。改为退避重试,等 qrcode + img_content 都就绪。 3. get_qrcode_status 轮询只 catch ReadTimeout:限流返回非 JSON 时 .json() 抛错崩溃。改为捕获所有 RequestException + ValueError 容错重试。 4. PNG 兜底依赖 PIL,缺失时 qrcode.make().save() 抛 ModuleNotFoundError, 且 traceback 被 finally 重定向到日志文件而难以发现。改为先打 ASCII 二维码(扫码真正所需,无依赖),PNG 保存包 try 失败不崩。 均为通用的容器化健壮性改进。 Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
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.
Uh oh!
There was an error while loading. Please reload this page.