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

‘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参数也必须

相关文章:

  • [前端]HTML模拟实现一个基于摄像头的手势识别交互页面
  • GitLab 拉取变慢的原因及排查方法
  • 【智算中心】以网补算
  • 力扣面试150题--单词接龙
  • React 集中状态管理方案
  • Windows安装docker及使用
  • 操作系统——第五章(I/O设备)
  • [架构之美]深入优化Spring Boot WebFlux应用
  • 机器学习-黑马笔记
  • STM32 开发 - 中断案例(中断概述、STM32 的中断、NVIC 嵌套向量中断控制器、外部中断配置寄存器组、EXTI 外部中断控制器、实例实操)
  • Python中的函数和方法概要
  • 【AS32系列MCU调试教程】硬件调试:JLink 驱动配置与调试技巧
  • MCU、MPU、GPU、Soc、DSP、FPGA、CPLD……它们到底是什么?
  • C# 结构(构造函数和析构函数)
  • BEV和OCC学习-8:mmdet3d 3D分割demo测试
  • stm32f103 标准库移植rt-thread nano
  • Django(自用)
  • 无人机遥控器低延迟高刷新技术解析
  • 38道Linux命令高频题整理(附答案背诵版)
  • [python] 使用python设计滤波器
  • 东阿网站建设产品/电商软文范例100字
  • 中国空间站真实图片/正规推广赚佣金的平台
  • 湖南省金力电力建设有限公司 网站/设计网络营销方案
  • 微官网和移动网站区别/优化模型
  • 把网站做静态化/抖音推广合作方式
  • 门头沟高端网站建设/浏览广告赚钱的平台