【问题标题】:Azure Pipeline "ChromeHeadless have not captured in 60000 ms, killing.", works on second try but sometimes exits with non zeroAzure Pipeline“ChromeHeadless 在 60000 毫秒内未捕获,正在杀死。”,在第二次尝试时工作,但有时以非零退出
【发布时间】:2021-11-16 01:23:28
【问题描述】:

我在使用 ng 测试时遇到间歇性构建失败,我认为与 ChromeHeadless 在未能正确连接后挂出的实例有关。我的 Azure 管道总是会发出一个 ChromeHeadless have not captured in 60000 ms, killing.(如 this 问题)的声音,但随后会正常运行单元测试。测试将通过大约一半的时间构建变为绿色。另一半我得到一个节点非零退出代码错误。

命令:ng test --code-coverage --browsers=ChromeHeadless --watch=false

成功日志:

2021-11-15T22:59:09.9297050Z > ng test --code-coverage --browsers=ChromeHeadless --watch=false
2021-11-15T22:59:09.9297547Z 
2021-11-15T22:59:09.9298696Z 15 11 2021 22:55:02.738:WARN [karma-server]: Passing raw CLI options to `new Server(config, done)` is deprecated. Use `parseConfig(configFilePath, cliOptions, {promiseConfig: true, throwErrors: true})` to prepare a processed `Config` instance and pass that as the `config` argument instead.
2021-11-15T22:59:09.9300540Z 15 11 2021 22:55:53.494:INFO [karma-server]: Karma v6.3.4 server started at http://localhost:9876/
2021-11-15T22:59:09.9302562Z 15 11 2021 22:55:53.495:INFO [launcher]: Launching browsers ChromeHeadless with concurrency unlimited
2021-11-15T22:59:09.9305118Z 15 11 2021 22:55:53.501:INFO [launcher]: Starting browser ChromeHeadless
2021-11-15T22:59:09.9306242Z 15 11 2021 22:56:53.528:WARN [launcher]: ChromeHeadless have not captured in 60000 ms, killing.
2021-11-15T22:59:09.9307283Z 15 11 2021 22:56:56.344:INFO [launcher]: Trying to start ChromeHeadless again (1/2).
2021-11-15T22:59:09.9308355Z 15 11 2021 22:57:08.714:INFO [Chrome Headless 95.0.4638.69 (Windows 10)]: Connected on socket 7GsL_H9cLK7nNS-0AAAB with id 24622884
2021-11-15T22:59:09.9309742Z Chrome Headless 95.0.4638.69 (Windows 10): Executed 0 of 5191[32m SUCCESS[39m (0 secs / 0 secs)
2021-11-15T22:59:09.9311289Z [1A[2KChrome Headless 95.0.4638.69 (Windows 10): Executed 1 of 5191[32m SUCCESS[39m (0 secs / 0.09 secs)

...snip a bunch of test lines...

2021-11-15T22:59:10.4682949Z [1A[2KChrome Headless 95.0.4638.69 (Windows 10): Executed 5191 of 5191[32m SUCCESS[39m (1 min 48.797 secs / 40.407 secs)
2021-11-15T22:59:10.4683432Z [32mTOTAL: 5191 SUCCESS[39m
2021-11-15T22:59:10.4683751Z TOTAL: 5191 SUCCESS
2021-11-15T22:59:10.4685421Z ##[debug]rm -rf D:\a\1\npm\1808514.npmrc
2021-11-15T22:59:10.4686006Z ##[debug]removing file D:\a\1\npm\1808514.npmrc
2021-11-15T22:59:10.4687970Z ##[debug]Agent.BuildDirectory=D:\a\1
2021-11-15T22:59:10.4688686Z ##[debug]rm -rf D:\a\1\npm
2021-11-15T22:59:10.4690143Z ##[debug]removing directory D:\a\1\npm
2021-11-15T22:59:10.4694691Z ##[section]Finishing: Running Unit Tests

失败日志:

2021-11-15T23:00:13.5726081Z > ng test --code-coverage --browsers=ChromeHeadless --watch=false
2021-11-15T23:00:13.5726931Z 
2021-11-15T23:00:13.5728815Z 15 11 2021 22:55:00.157:WARN [karma-server]: Passing raw CLI options to `new Server(config, done)` is deprecated. Use `parseConfig(configFilePath, cliOptions, {promiseConfig: true, throwErrors: true})` to prepare a processed `Config` instance and pass that as the `config` argument instead.
2021-11-15T23:00:13.5731137Z 15 11 2021 22:56:23.079:INFO [karma-server]: Karma v6.3.4 server started at http://localhost:9876/
2021-11-15T23:00:13.5733401Z 15 11 2021 22:56:23.081:INFO [launcher]: Launching browsers ChromeHeadless with concurrency unlimited
2021-11-15T23:00:13.5735288Z 15 11 2021 22:56:23.087:INFO [launcher]: Starting browser ChromeHeadless
2021-11-15T23:00:13.5736548Z 15 11 2021 22:57:24.479:WARN [launcher]: ChromeHeadless have not captured in 60000 ms, killing.
2021-11-15T23:00:13.5737814Z 15 11 2021 22:57:34.284:INFO [launcher]: Trying to start ChromeHeadless again (1/2).
2021-11-15T23:00:13.5739190Z 15 11 2021 22:58:00.870:INFO [Chrome Headless 95.0.4638.69 (Windows 10)]: Connected on socket C0MkTPwSkT-fXggHAAAB with id 78277967
2021-11-15T23:00:13.5740882Z Chrome Headless 95.0.4638.69 (Windows 10): Executed 0 of 5191[32m SUCCESS[39m (0 secs / 0 secs)
2021-11-15T23:00:13.5743230Z [1A[2KChrome Headless 95.0.4638.69 (Windows 10): Executed 1 of 5191[32m SUCCESS[39m (0 secs / 0.103 secs)

...snip a bunch of test lines...

2021-11-15T23:00:14.2929797Z [1A[2KChrome Headless 95.0.4638.69 (Windows 10): Executed 5191 of 5191[32m SUCCESS[39m (0 secs / 48.607 secs)
2021-11-15T23:00:14.2930731Z 15 11 2021 23:00:12.864:WARN [Chrome Headless 95.0.4638.69 (Windows 10)]: Disconnected (0 times) reconnect failed before timeout of 2000ms (ping timeout)
2021-11-15T23:00:14.2931733Z [1A[2K[31mChrome Headless 95.0.4638.69 (Windows 10) ERROR[39m
2021-11-15T23:00:14.2932881Z   Disconnected reconnect failed before timeout of 2000ms (ping timeout)
2021-11-15T23:00:14.2933725Z Chrome Headless 95.0.4638.69 (Windows 10): Executed 5191 of 5191[31m DISCONNECTED[39m (2 mins 1.613 secs / 48.607 secs)
2021-11-15T23:00:14.2934480Z Chrome Headless 95.0.4638.69 (Windows 10) ERROR
2021-11-15T23:00:14.2935136Z   Disconnected reconnect failed before timeout of 2000ms (ping timeout)
2021-11-15T23:00:14.2935937Z [1A[2KChrome Headless 95.0.4638.69 (Windows 10): Executed 5191 of 5191[31m DISCONNECTED[39m (2 mins 1.613 secs / 48.607 secs)

... snip some config output...

2021-11-15T23:00:14.3395972Z ##[debug]pattern: '*-debug.log'
2021-11-15T23:00:14.3396710Z ##[debug]findPath: 'C:\npm\cache\_logs'
2021-11-15T23:00:14.3397422Z ##[debug]statOnly: 'false'
2021-11-15T23:00:14.3398156Z ##[debug]findPath: 'C:\npm\cache\_logs'
2021-11-15T23:00:14.3399116Z ##[debug]findOptions.allowBrokenSymbolicLinks: 'false'
2021-11-15T23:00:14.3399977Z ##[debug]findOptions.followSpecifiedSymbolicLink: 'true'
2021-11-15T23:00:14.3400817Z ##[debug]findOptions.followSymbolicLinks: 'true'
2021-11-15T23:00:14.3401559Z ##[debug]0 results
2021-11-15T23:00:14.3402490Z ##[debug]found 0 paths
2021-11-15T23:00:14.3404014Z ##[debug]applying include pattern
2021-11-15T23:00:14.3405865Z ##[debug]adjustedPattern: 'C:\npm\cache\_logs\*-debug.log'
2021-11-15T23:00:14.3407657Z ##[debug]0 matches
2021-11-15T23:00:14.3409050Z ##[debug]0 final results
2021-11-15T23:00:14.3410115Z ##[debug]Trying debug log location: D:\a\1\s\npm-debug.log
2021-11-15T23:00:14.3457007Z ##[warning]Couldn't find a debug log in the cache or working directory
2021-11-15T23:00:14.3478105Z ##[debug]Processed: ##vso[task.issue type=warning;]Couldn't find a debug log in the cache or working directory
2021-11-15T23:00:14.3479818Z ##[debug]Agent.BuildDirectory=D:\a\1
2021-11-15T23:00:14.3480813Z ##[debug]rm -rf D:\a\1\npm
2021-11-15T23:00:14.3482353Z ##[debug]removing directory D:\a\1\npm
2021-11-15T23:00:14.3483408Z ##[debug]task result: Failed
2021-11-15T23:00:14.3485013Z ##[error]Error: Npm failed with return code: 1
2021-11-15T23:00:14.3486527Z ##[debug]Processed: ##vso[task.issue type=error;]Error: Npm failed with return code: 1
2021-11-15T23:00:14.3496428Z ##[debug]Processed: ##vso[task.complete result=Failed;]Error: Npm failed with return code: 1
2021-11-15T23:00:14.3500802Z ##[section]Finishing: Running Unit Tests

认为正在发生的事情是,由于顶部的错误,单元测试的多个实例被分拆,然后我们遇到了竞争条件:有时“断开连接”单元测试首先完成并且构建保持绿色。有时,第二个“实时”集首先完成,当“断开连接”的一个尝试终止并清理时,它发现日志文件夹被删除或代码1出现错误。不过,我对如何验证该假设感到困惑。我尝试将 karma 的 retryLimit 设置为 1(默认为 2),但这似乎不会影响初始启动。

【问题讨论】:

  • 原来我正在解决两个问题。 ChromeHeadless have not captured in 60000 ms, killing 方面有点像红鲱鱼。它在日志中增加了一些噪音,但并不是实际构建失败的原因。韦斯利在下面的回答确实解决了上述错误
  • 我遇到了一些链接问题,但以下调整让我的 CI 构建恢复了快乐。这SO question 帮助了。我需要browserDisconnectTimeoutbrowserNoActivityTimeout 选项集以及--disable-gpu--no-sandbox 标志
  • 我之前的评论说得太早了。我仍然看到断开连接失败。在我的配置中设置 browserDisconnectTolerance 已经缓解了这个问题,但这感觉像是在治疗症状,而不是根本问题。

标签: angular azure-devops karma-jasmine


【解决方案1】:

我注意到在这两种情况下您都会看到ChromeHeadless have not captured in 问题。在成功启动之前大约需要 1 分 15 秒。 我会做一些假设

  • 您有相当多的代码正在编译运行
  • 您正在使用流水线中的代理(我想说它并不过分强大)

好消息是 karma 有一个captureTimeout,默认为 60,000。我相信如果您将此设置添加到 karma.conf 并将其加倍,您将为 chrome 提供时间来处理您正在加载的所有测试。

您可能会遇到第二个问题,即您的测试非常激烈,以至于 chrome 有时停止响应的时间超过 browserDisconnectTimeout

【讨论】:

  • 感谢您的洞察力,我会试一试,看看情况如何。
  • 这解决了这个问题的“ChromeHeadless 没有被捕获”部分。我仍然收到“在 2000 毫秒(ping 超时)超时之前断开连接(0 次)重新连接失败”方面,所以我认为可以肯定地说我在这里遇到了多个问题。但是,这将有助于指导我的故障排除。谢谢!
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 2014-07-13
  • 2017-01-07
  • 2017-08-31
  • 2017-08-31
  • 2020-07-18
  • 2016-12-12
  • 2020-01-07
相关资源
最近更新 更多