Repository navigation
fix(captcha): 补齐 puppeteer-core lock 并修复 Chromium 进程泄漏(关联 #1) - #12
Open
zephyr-xiao wants to merge 1 commit into
Open
zephyr-xiao wants to merge 1 commit into
zephyr-xiao wants to merge 1 commit into
Conversation
- captcha_node/package-lock.json 补 puppeteer-core:2.6.3 加依赖时未更新 lock, npm ci 直接失败,真浏览器求解器起不来 - solver_pw.js:记录 Chromium PID,exit 钩子 + 硬超时(早于调用方 20s)自我清场, 防止被 SIGKILL 时留下已 setsid 逃逸、killpg 打不到的 Chromium - captcha.py:按 PPID==1 + cmdline 特征清扫孤儿 Chromium 兜底(单实例约 360MB) 关联 issue dengyie#1:验证码 500/4028 的部分成因即求解器无法启动与进程堆积; Windows 用户另需把 ZCODE_CHROMIUM_PATH 指到本机 Chromium(上游已有该配置项)。
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.
问题
npm ci失败,真浏览器求解器起不来:2.6.3 给captcha_node/package.json加了puppeteer-core依赖,但package-lock.json没有同步更新。任何按 lock 安装的部署(Docker、CI、npm ci)都会直接报错,验证码求解必然失败,表现为验证码求解失败: 多次重试无结果 (HTTP 500) (4028)(issue 无法完成人机校验: 验证码求解失败: 多次重试无结果 (HTTP Status: 500) (4028) #1)。setsid脱离 node 的进程组(PGID=SESS=自身)。node 正常退出时还能由 exit 钩子清理,但求解超时被SIGKILL或同步卡死时,killpg(node 组)打不到它,每个残留实例约 360MB,长时间运行会把小内存机器拖死。修法
captcha_node/package-lock.json:补齐puppeteer-core及其依赖树。captcha_node/solver_pw.js:process.on("exit")同步补杀(覆盖正常退出、exit(code)、未捕获异常);exit(2),避免挂死迫使调用方SIGKILL留下逃逸进程。app/captcha.py:按PPID==1+ cmdline 含 chromium 特征清扫孤儿进程兜底(并发求解中活跃 Chromium 的父进程是活着的 node,PPID≠1,不会误杀;非 Linux 无/proc时直接跳过)。验证
ps可见多个 PPID=1 的 Chromium 常驻;修复后连续多轮求解不再堆积。附注
Windows 用户遇到
4028还需把ZCODE_CHROMIUM_PATH指到本机 Chromium 可执行文件(该配置项上游已支持,默认值/usr/local/bin/chromium只适用于容器)。issue #1 评论里提到的「改一下 Chromium 路径」即此。