当前位置: 首页 > ds >正文

‘Target closed‘ error in Puppeteer解决

背景

业务应用需要将系统从centos切换ubuntu,其中A应用在准备好相应的ubuntu镜像后,在mac本机启容器,执行测试脚本报错

"Error: Protocol error (Target.setDiscoverTargets): Target closed."

排查

1.看Chromium 错误日志

   添加dumpio: true,这会把 Chromium 启动过程的 stderr 输出都打到控制台

const browser = await puppeteer.launch({headless: true,args: [...],dumpio: true
});

2.执行后,关键报错如下

[0612/162451.208800:FATAL:zygote_main_linux.cc(163)] Check failed: sandbox::ThreadHelpers::IsSingleThreaded().
[0612/162451.595965:ERROR:file_path_watcher_linux.cc(318)] inotify_init() failed: Function not implemented (38)
qemu: unknown option 'type=gpu-process'DevTools listening on ws://127.0.0.1:33643/devtools/browser/cab2bfec-926e-4e7b-b53e-46157b3a6032
[0612/162451.770694:WARNING:gpu_process_host.cc(1206)] The GPU process has crashed 1 time(s)
qemu: unknown option 'type=gpu-process'
[0612/162451.831737:WARNING:gpu_process_host.cc(1206)] The GPU process has crashed 2 time(s)
qemu: unknown option 'type=gpu-process'
[0612/162451.861199:WARNING:gpu_process_host.cc(1206)] The GPU process has crashed 3 time(s)
qemu: unknown option 'type=gpu-process'
[0612/162451.874366:WARNING:gpu_process_host.cc(1206)] The GPU process has crashed 4 time(s)
qemu: unknown option 'type=gpu-process'
[0612/162451.884288:WARNING:gpu_process_host.cc(1206)] The GPU process has crashed 5 time(s)
qemu: unknown option 'type=gpu-process'
[0612/162451.893254:WARNING:gpu_process_host.cc(1206)] The GPU process has crashed 6 time(s)
qemu: unknown option 'type=gpu-process'
[0612/162451.908820:WARNING:gpu_process_host.cc(1206)] The GPU process has crashed 7 time(s)
qemu: unknown option 'type=gpu-process'
[0612/162451.936704:WARNING:gpu_process_host.cc(1206)] The GPU process has crashed 8 time(s)
qemu: unknown option 'type=gpu-process'
[0612/162451.995340:WARNING:gpu_process_host.cc(1206)] The GPU process has crashed 9 time(s)
[0612/162451.995588:FATAL:gpu_data_manager_impl_private.cc(918)] The display compositor is frequently crashing. Goodbye.(node:499) UnhandledPromiseRejectionWarning: Unhandled promise rejection (rejection id: 1): Error: Protocol error (Target.setDiscoverTargets): Target closed.
(node:499) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.

3.根据报错关键字搜索查到类似issue(https://github.com/puppeteer/puppeteer/issues/7746),提供的解决方案有两种

方案测试结果引申
1Docker desktop启用beta功能:'Use Rosetta for x86/amd64 emulation on Apple Silicon' mac机系统版本不满足,无法测试

1.Rosetta 2介绍

2.ARM 和 x86_64是什么关系
 

2chromium args参数增加--single-process

1.经测试,该方案可行

2.--no-sandbox参数也必须

http://www.xdnf.cn/news/13812.html

相关文章:

  • python打卡day52
  • 【GitOps】Kubernetes安装ArgoCD,使用阿里云MSE云原生网关暴露服务
  • 大数据学习(138)-Hive数据分析3
  • 利用Anything LLM和内网穿透工具在本地搭建可远程访问的AI知识库系统(1)
  • (十二)深度学习计算性能:硬件架构、算法效率与理论极限分析
  • Cursor 编辑器中的 Notepad 功能使用指南
  • sherpa-onnx开源语音处理框架研究报告:从技术解析到应用实践
  • Linux中shell编程的函数递归用法和脚本自动化讲解
  • 什么是JSON ?从核心语法到编辑器
  • 无人机避障——感知篇(在Ubuntu20.04的Orin nx上基于ZED2实现Vins Fusion)
  • 【cobalt strike手册】CS的环境配置
  • 离线部署openstack 2024.1 placement
  • Windows11下搭建Black Magic Probe (BMP) 编译环境
  • 【Unity踩坑】Unity 6在Mac平台编译运行时去除‘trial version‘
  • 第七章——8天Python从入门到精通【itheima】-81~84(函数的多返回值+函数多种传参方式+函数作为参数传递+lambda函数)
  • 剑指offer22_合并两个排序的链表
  • 【C】 USB CDC、Bulk-OUT 端点
  • 观测云,全球领先的监控观测平台亮相亚马逊云科技中国峰会!
  • 迭代优化法解决问题实例
  • day27/60重写(补充)
  • 流体仿真CFD技术在好氧活性污泥曝气系统改造中的应用
  • module_obj笔记
  • 手阳明大肠经之温溜穴
  • MySQL基础知识(DDL、DML)
  • YOLO-FireAD:通过混合注意力与双池化融合实现高精度实时火灾检测
  • 【PyQt5】从零开始的PyQt5 - QTextEdit 篇
  • 2025北京智源大会核心内容
  • RAG系统中Rerank技术的深度解析与应用实践
  • DNS的工作原理
  • 【AI News | 20250611】每日AI进展