Skip to content

修复个人微信前端在 headless 容器内无法登录#595

Open
Michaelxwb wants to merge 5 commits into
lsdefine:mainfrom
Michaelxwb:main
Open

修复个人微信前端在 headless 容器内无法登录#595
Michaelxwb wants to merge 5 commits into
lsdefine:mainfrom
Michaelxwb:main

Conversation

@Michaelxwb

@Michaelxwb Michaelxwb commented Jun 11, 2026

Copy link
Copy Markdown
image @lsdefine 帮忙合一下

Michaelxwb and others added 5 commits June 11, 2026 09:15
容器化部署时个人微信前端无法首次扫码登录,定位并修复 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>
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