Skip to content

Commit c801a12

Browse files
authored
fix(mobile): release leased device session before stopping daemon (#1900)
* fix(mobile): release leased device session before stopping daemon * docs(mobile): clarify session cleanup failure phrasing on stop fallback * fix(mobile): cap RPC lease release budget and simplify release stage * fix(mobile): size RPC release timeout from cleanup budget * fix(mobile): reserve stop budget and preserve provider release warnings * refactor(mobile): simplify lease release checks and widen hung-DELETE test budget * fix(mobile): enforce minimum lease RPC budget and clarify RPC timeout error * test(mobile): isolate mock BrowserStack details endpoint and scale RPC budget * chore(changeset): remove em dashes from release note
1 parent d32dc7c commit c801a12

18 files changed

Lines changed: 734 additions & 63 deletions

File tree

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
'@e2e-dev/mobile': patch
3+
---
4+
5+
Fix BrowserStack, TestMu AI, and Revyl runs on Windows failing during cleanup with `could not confirm its sessions ended` and leaving the device session open until idle timeout, and fail the release when any agent-device lease provider rejects ending the session (with the default `cleanupTimeout`).

‎docs/integrations/browserstack.mdx‎

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -133,10 +133,12 @@ the same video. Runs that overlap and share a fixed `build` and
133133
- If the runner is killed before it releases a device, BrowserStack's idle
134134
timeout ends the session after its last command.
135135
- A release fails the run when agent-device can't confirm it ended the
136-
session, even when every test passed. The causes: the session end ran past
137-
agent-device's shutdown window of about 3 seconds, a forced daemon stop, a
138-
lost shutdown report, or a daemon that exited during the run. Find the
139-
session on the dashboard by its `build` and `sessionName`.
136+
session, even when every test passed. This happens when BrowserStack session
137+
cleanup fails (with more than 20 seconds of `cleanupTimeout` remaining) or
138+
goes unconfirmed across daemon stop, or when the daemon exits during the run.
139+
On Windows, ending the session before daemon stop also requires more than
140+
20 seconds of remaining `cleanupTimeout` (keep the default 30 seconds). Find
141+
the session on the dashboard by its `build` and `sessionName`.
140142
- Device settings (permissions, location, network, appearance), system
141143
alerts, recording and device logs through agent-device, and port reverse
142144
are not available. Read logs on the BrowserStack dashboard, and use

‎docs/integrations/revyl.mdx‎

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -121,6 +121,12 @@ Unknown or invalid options fail config load with `INVALID_CONFIG`.
121121
device when the run finishes or is interrupted.
122122
- If the runner is killed before it releases a device, nothing sends the
123123
session another command, and Revyl ends it after 5 minutes idle.
124+
- A release fails the run when agent-device can't confirm it ended the
125+
session, even when every test passed. This happens when Revyl session
126+
cleanup fails (with more than 20 seconds of `cleanupTimeout` remaining) or
127+
goes unconfirmed across daemon stop, or when the daemon exits during the run.
128+
On Windows, ending the session before daemon stop also requires more than
129+
20 seconds of remaining `cleanupTimeout` (keep the default 30 seconds).
124130
- `app` must be reachable over `https` without credentials in the URL. A
125131
presigned storage URL works. Set `app` or `app.appPath`, not both.
126132
- An `app.appPath` build is uploaded to each device's own session, so a run

‎docs/integrations/testmu.mdx‎

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -228,9 +228,12 @@ An attempt that records [video](/reference/config#video) gets:
228228
command.
229229
- **Unconfirmed release fails the run.** A release fails the run when
230230
agent-device can't confirm it ended the device session, even when every
231-
test passed: a forced daemon stop, a lost shutdown report, or a daemon that
232-
exited during the run. Find the session on the dashboard by its `build` and
233-
`sessionName`.
231+
test passed. This happens when TestMu AI session cleanup fails (with more
232+
than 20 seconds of `cleanupTimeout` remaining) or goes unconfirmed across
233+
daemon stop, or when the daemon exits during the run. On Windows, ending the
234+
session before daemon stop also requires more than 20 seconds of remaining
235+
`cleanupTimeout` (keep the default 30 seconds). Find the session on the
236+
dashboard by its `build` and `sessionName`.
234237
- **Device settings and logs.** Device settings (permissions, location,
235238
network, appearance), system alerts, recording and device logs through
236239
agent-device, and port reverse are not available. Read logs on the TestMu

‎docs/ja/integrations/browserstack.mdx‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -125,8 +125,8 @@ BrowserStack のセッション録画へのリンクが付きます。録画は
125125
`https` の `app` を指定した実行では再アップロードします。これを省くには `bs://` ID を再利用してください。
126126
- デバイスを解放する前にランナーが強制終了された場合は、最後のコマンドからアイドルタイムアウトの時間が経つと、BrowserStack がセッションを終了します。
127127
- agent-device がセッション終了を確認できない場合、すべてのテストが成功していても、解放処理によって実行が失敗します。
128-
原因としては、セッション終了が agent-device の約 3 秒のシャットダウン猶予を超えた、デーモンが強制停止された、
129-
シャットダウンレポートが失われた、実行中にデーモンが終了した、といったケースがあります。
128+
BrowserStack でのセッションクリーンアップが失敗したか(残りの `cleanupTimeout` が 20 秒を超える場合)、デーモン停止時の確認が取れなかった場合、または実行中にデーモンが終了した場合に発生します。
129+
Windows でデーモン停止前にセッションを終了するには、残りの `cleanupTimeout` が 20 秒を超える必要があります(デフォルトの 30 秒のままにしてください)。
130130
ダッシュボードでは `build` と `sessionName` でセッションを探してください。
131131
- デバイス設定(権限、位置情報、ネットワーク、外観)、システムアラート、agent-device 経由の録画とデバイスログ、
132132
ポートリバースは利用できません。ログは BrowserStack ダッシュボードで確認し、ネットワーク内のサーバーへの接続には BrowserStack Local を使ってください。

‎docs/ja/integrations/testmu.mdx‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -216,7 +216,8 @@ testmuBrowsers({
216216
(デフォルトは 120 秒)により、最後のコマンドから約 3 分後に終了します。
217217
- **解放を確認できないと実行が失敗します。** agent-device がデバイスセッションの終了を確認できない場合、
218218
すべてのテストが成功していても、解放処理によって実行が失敗します。
219-
原因には、デーモンの強制停止、シャットダウンレポートの消失、実行中のデーモン終了があります。
219+
TestMu AI でのセッションクリーンアップが失敗したか(残りの `cleanupTimeout` が 20 秒を超える場合)、デーモン停止時の確認が取れなかった場合、または実行中にデーモンが終了した場合に発生します。
220+
Windows でデーモン停止前にセッションを終了するには、残りの `cleanupTimeout` が 20 秒を超える必要があります(デフォルトの 30 秒のままにしてください)。
220221
ダッシュボードでは `build` と `sessionName` でセッションを探してください。
221222
- **デバイス設定とログ。** デバイス設定(権限、位置情報、ネットワーク、外観)、システムアラート、
222223
agent-device 経由の録画とデバイスログ、ポートリバースは利用できません。

‎docs/mobile.mdx‎

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -688,10 +688,11 @@ an interrupt `signal`, and a `log` that reaches the reporter.
688688

689689
**`release`** runs after the last worker exits, within `cleanupTimeout`, on
690690
every exit path: a failure, an interrupt, or a `prepare` that threw. It gets
691-
the object `acquire` returned, so a provider can keep its own fields on it.
692-
Only the `DeviceLease` fields reach the workers. When one slot fails to
693-
lease, the run ends before any test, and the engine still releases every
694-
lease it got.
691+
the object `acquire` returned, so a provider can keep its own fields on it,
692+
and `context` carrying `timeoutMs`, the remaining cleanup budget, in
693+
milliseconds, when `release` starts. Only the `DeviceLease` fields reach the
694+
workers. When one slot fails to lease, the run ends before any test, and the
695+
engine still releases every lease it got.
695696

696697
**`client`** is agent-device client configuration, as JSON data, applied on
697698
top of the session name and the `daemon` address. A lease that sets

‎docs/zh/integrations/browserstack.mdx‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -103,5 +103,5 @@ test('Wikipedia home screen', async ({ app, screen }) => {
103103
- e2e 准备测试目标时,每个会话会在租用其槽位的设备时开始。设备准备约需 20 至 50 秒,会话会一直计费到运行释放它,即使没有测试在其上执行。`workers` 与 BrowserStack 测试目标数量的乘积不得超过套餐允许的并行会话数。
104104
- BrowserStack 会在上传内容最后一次使用后保留 30 天。使用 `https` `app` 的运行会再次上传;复用 `bs://` ID 可跳过上传。
105105
- 如果运行器在释放设备前被终止,BrowserStack 会在最后一条命令后达到空闲超时时结束会话。
106-
- 如果 agent-device 无法确认已结束会话,释放操作会导致运行失败,即使所有测试都已通过。可能的原因包括:结束会话超过 agent-device 约 3 秒的关闭时间窗口、守护进程被强制停止、关闭报告丢失,或守护进程在运行期间退出。通过 `build` 和 `sessionName` 在控制台中查找会话。
106+
- 如果 agent-device 无法确认已结束会话,释放操作会导致运行失败,即使所有测试都已通过。这会在 BrowserStack 会话清理失败(剩余 `cleanupTimeout` 超过 20 秒时)、守护进程停止后仍未确认结束,或守护进程在运行期间退出时发生。在 Windows 上,在停止守护进程前结束会话也需要剩余 `cleanupTimeout` 超过 20 秒(建议保留默认的 30 秒)。通过 `build` 和 `sessionName` 在控制台中查找会话。
107107
- 不支持设备设置(权限、位置、网络、外观)、系统警报、通过 agent-device 录制和读取设备日志,以及端口反向转发。在 BrowserStack 控制台读取日志,使用 BrowserStack Local 访问你网络中的服务器。

‎docs/zh/integrations/testmu.mdx‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -182,7 +182,7 @@ testmuBrowsers({
182182
- **并行会话。** `workers` 乘以 TestMu AI 测试目标数量,不应超过套餐允许的并行会话数。超出套餐限制的浏览器会话会在 TestMu AI 的队列中等待。
183183
- **设备会话在租用期间计费。** 设备会话在槽位租用时启动,此过程约需 30 到 75 秒。即使没有测试在设备上运行,也会持续计费,直到运行释放设备。
184184
- **设备上的运行器被停止。** 如果运行器在释放设备之前被终止,就不会再有命令发送到会话。TestMu AI 的[空闲超时](https://www.lambdatest.com/support/docs/desired-capabilities-in-appium/)(默认为 120 秒)会在最后一条命令后约三分钟结束会话。
185-
- **无法确认释放会导致运行失败。** 当 agent-device 无法确认已结束设备会话时,即使所有测试都通过,释放操作也会导致运行失败:例如守护进程被强制停止、关闭报告丢失,或守护进程在运行期间退出。通过 `build` 和 `sessionName` 在控制台中查找会话。
185+
- **无法确认释放会导致运行失败。** 当 agent-device 无法确认已结束设备会话时,即使所有测试都通过,释放操作也会导致运行失败:这会在 TestMu AI 会话清理失败(剩余 `cleanupTimeout` 超过 20 秒时)、守护进程停止后仍未确认结束,或守护进程在运行期间退出时发生。在 Windows 上,在停止守护进程前结束会话也需要剩余 `cleanupTimeout` 超过 20 秒(建议保留默认的 30 秒)。通过 `build` 和 `sessionName` 在控制台中查找会话。
186186
- **设备设置和日志。** 不支持设备设置(权限、位置、网络、外观)、系统提示框、通过 agent-device 录制和读取设备日志,以及端口反向转发。在 TestMu AI 控制台中读取日志,并使用 TestMu AI Tunnel 访问你所在网络上的服务器。
187187
- **浏览器连接限时 60 秒。** 网页端引擎最多等待 60 秒,让浏览器会话接受 CDP 连接。更短的 `launchTimeout` 会提前结束等待,但更长的值不会延长等待。超过该时间仍在排队或准备中的会话会以 `LAUNCH_TIMEOUT` 失败;当 `launchTimeout` 超过 60 秒时,则以 `ENGINE_FAILURE` 失败。
188188
- **浏览器连接中断。** 浏览器会话无法恢复,因此连接中断会导致尝试失败。

‎packages/browserstack/src/provider.ts‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,8 @@ export interface BrowserStackOptions {
9999
* BrowserStack devices for `mobile({ device: browserstack({ device, osVersion, app }) })`:
100100
* one real device and isolated agent-device daemon per worker slot. The
101101
* session starts, and installs `app`, when the daemon allocates the lease;
102-
* releasing the lease stops the daemon, which ends the session.
102+
* releasing the lease ends the session via the daemon before stopping it
103+
* (falling back to daemon stop if the RPC does not confirm release).
103104
*/
104105
export function browserstack(options: BrowserStackOptions): DeviceProvider {
105106
if (typeof options !== 'object' || options === null || Array.isArray(options)) {

0 commit comments

Comments
 (0)