Skip to content

fix: make waitBootComplete honour its timeout - #84

Merged
Shinrai merged 4 commits into
nextfrom
deps/adbkit-4
Nov 1, 2026
Merged

Shinrai merged 4 commits into
nextfrom
deps/adbkit-4

Conversation

@cldmv-bot

@cldmv-bot cldmv-bot Bot commented Nov 1, 2026 •

Copy link
Copy Markdown
Contributor

🚀 What's Changed

💥 Breaking Changes

No breaking changes

✨ Features

No new features

🐛 Bug Fixes

📦 Dependencies

🔧 Other Changes

👥 Contributors

Mocks the adbkit client and device and drives client creation,
connect/disconnect, the heartbeat and connection check, auto-disconnect,
key/long-press/text shell commands, setSettings, ensureAwake, reboot,
screencap/thumbnail and waitBootComplete, plus a check that the real
package still has the client, device and util methods the remote calls.
Line coverage of src/lib/android-tv-remote.mjs goes from 24% to 95%.
Breaking changes in 4.0.0 (DeviceFarmer/adbkit#567, #568) and how they
apply here:

- Native promises replace bluebird; bluebird-only methods (.timeout,
  .delay, .return, .cancel, .catch(Class, fn)) are gone. Doesn't apply:
  the remote only uses .then/.catch and await on adbkit promises.
- Cancellation is explicit (AbortSignal on parser reads, tracker.end(),
  transfer.cancel(), a signal option on waitBootComplete/waitForDevice).
  Doesn't apply: we don't use trackers, sync transfers or cancellation;
  waitBootComplete() is still called without options.
- Deep imports outside the new exports map no longer resolve. Doesn't
  apply: only the package root is imported; the default-import shape
  (.Adb) is unchanged.
- Node.js 22.12 or later is required. Already met: engines.node is
  >=22.22.0.
- Unawaited internal promise chains now warn instead of crashing. Doesn't
  apply: no trackers, sync transfers or ProcStat in use.
- adbkit-logcat 3 / adbkit-monkey 2. Doesn't apply: openLogcat() and
  openMonkey() aren't used.

No source changes were needed.
@cldmv-bot cldmv-bot Bot added ! deps → next v4 flow: deps contributor PR targeting the next integration branch area: tests Touches test files, fixtures, or test infrastructure type: dependencies Relates to dependency updates, version bumps, or package management labels Nov 1, 2026
@cldmv-bot cldmv-bot Bot changed the title deps: bump @devicefarmer/adbkit to 4.0.1 test: cover every code path that calls into adbkit Nov 1, 2026
@cldmv-bot

cldmv-bot Bot commented Nov 1, 2026

Copy link
Copy Markdown
Contributor Author

Auto-normalized PR title: rewrote PR title to match the highest-priority commit type (test).

  • Before: deps: bump @devicefarmer/adbkit to 4.0.1
  • After: test: cover every code path that calls into adbkit

If this isn't what you want, edit the title — the normalizer won't re-fire as long as the title stays conventional.

waitBootComplete(timeout) took a timeout but never passed it on, so the
wait ran until the device finished booting however long that took. It
now hands adbkit 4 an AbortSignal.timeout(timeout); adbkit rejects with
a TimeoutError and closes the connection when it fires, which reaches
the existing "Boot completion timeout" hint.

Closes #85
screencap({ width/height, filepath }) ended the file stream and emitted
"screencap-saved"/"screencap-complete" straight away, before the data
had reached the file, and a failing write stream had no error listener.
The background job now runs capture -> resize -> file through
stream/promises pipeline(), so the events fire and the job settles only
after the file is fully written, and a write failure tears the pipeline
down and is emitted as a "screencap" error with no completion events.

Closes #86
@cldmv-bot cldmv-bot Bot changed the title test: cover every code path that calls into adbkit fix: make waitBootComplete honour its timeout Nov 1, 2026
@cldmv-bot cldmv-bot Bot added the area: core Touches core library / runtime source code label Nov 1, 2026
@Shinrai
Shinrai merged commit 3bdf27d into next Nov 1, 2026
28 checks passed
@cldmv-bot
cldmv-bot Bot deleted the deps/adbkit-4 branch November 1, 2026 23:46
cldmv-bot Bot added a commit that referenced this pull request Nov 2, 2026
# `@cldmv/node-android-tv-remote` v2.2.0 Changelog

**Release Date**: November 2026
**Release Type**: Minor
**Branch**: `release/2.2.0`

---

## Overview

Version 2.2.0 moves the package to the CLDMV library layout with a tsup build, moves the runtime dependency `@devicefarmer/adbkit` to its new major 4, and fixes two long-standing bugs: `waitBootComplete(timeout)` now actually stops waiting at its timeout, and `screencap()` with a `filepath` no longer reports the file saved before it is written.

The supported Node.js range changes: `engines.node` goes from `>=20.9.0` to `>=22.22.0`, and `@devicefarmer/adbkit` 4 itself requires Node.js 22.12 or later. That is a real requirement change even though it ships in a minor release; see [Breaking Changes](#-breaking-changes) and the upgrade notes. The exported API (`createRemote`, `createAndroidTVRemote` and the default export, from both `import` and `require()`) is unchanged.

---

## 💥 Breaking Changes

### Node.js `>=22.22.0` is now required ([#81](#81))

`engines.node` was `>=20.9.0` in v2.1.9 (set by `sharp`), with `require()` documented as needing `^20.19.0` or `>=22.12.0`. Both are now `>=22.22.0`. The new build toolchain no longer runs on Node.js 20 (tsup 9 alone declares `^22.18.0 || ^24.11.0 || >=26.0.0`), and `@devicefarmer/adbkit` 4 declares `>= 22.12`, so Node.js 20 is no longer supported at runtime either. The floor is set to 22.22.0, the oldest version the CI and publish matrices now test. The `ERR_REQUIRE_ESM` message that `require()` throws on a Node.js without `require(esm)` now names `>=22.22.0`.

npm prints an `EBADENGINE` warning when installing on an older Node.js, and the install fails when `engine-strict` is set.

### `waitBootComplete()` now rejects at its timeout ([#84](#84), fixes [#85](#85))

This is a bug fix, listed here because it changes what a caller sees. `waitBootComplete(timeout = 60000)` documented a timeout but never passed it on, so the call waited until the device finished booting, however long that took. See [Bug Fixes](#-bug-fixes) for the details.

---

## 🐛 Bug Fixes

### `waitBootComplete(timeout)` honors its timeout ([#84](#84), fixes [#85](#85))

The remote now hands adbkit 4 an `AbortSignal.timeout(timeout)`. When it fires, adbkit closes the connection and rejects with a `TimeoutError`; the remote logs the existing "Boot completion timeout after …ms" message, emits the error, and rejects. A call with no argument now gives up after the documented 60 seconds instead of waiting indefinitely.

### `screencap()` finishes writing a resized screenshot before reporting it saved ([#84](#84), fixes [#86](#86))

With a `filepath` (and optionally `width` / `height`), the background save ended the file stream and emitted `screencap-saved` and `screencap-complete` straight away, before the data reached the file, and the file stream had no `error` listener. The capture, resize and file write now run through `stream/promises` `pipeline()`: the two events fire, and `lastScreencapData` is set, only after the file is fully written. A capture, resize or write failure tears the whole pipeline down and is reported as a `screencap` error with no completion events.

---

## ✨ Features

### Library layout: `src/` entries and a tsup build ([#81](#81), fixes [#75](#75))

The hand-written root `index.mjs` / `index.cjs` moved to `src/index.mjs` / `src/index.cjs`, and `build` is now tsup (`tsup.config.mjs`) instead of an `echo` stub:

- `dist/index.mjs` is a minified ESM bundle of `src/index.mjs`, with names and `node:` specifiers kept. The keycode, keyboard and remote-key JSON tables are inlined. The runtime dependencies (`@devicefarmer/adbkit`, `sharp`) stay external.
- `dist/index.cjs` is not a second bundle. It is a verbatim copy of `src/index.cjs`, the thin wrapper that loads `./index.mjs` through Node's synchronous `require(esm)` and keeps the historical CommonJS shape (`module.exports` is `createRemote`, with `createRemote`, `createAndroidTVRemote` and `default` on it).

`main` / `module` point at `dist/`, `exports` adds `./package.json`, and `prepack` runs the build so `dist/` is never committed. The published files are now `dist/` (without source maps) and `scripts/postinstall.mjs`, which still runs on install to check for `adb`. `src/` and the other two helper scripts are no longer published: `scripts/setup-device.mjs` and `scripts/wake-tv.mjs` import `src/`, so they are checkout tools (`npm run setup-device` in a clone of this repository).

### `node-android-tv-remote-dev` export condition ([#81](#81))

The `"."` export carries a `node-android-tv-remote-dev` condition that points `import` and `require` at `src/`. In a checkout, `node --conditions=node-android-tv-remote-dev` runs the unbuilt source; without it the package resolves to `dist/`, which `npm run build` produces. Installed copies only ship `dist/`.

---

## 🔧 CI & tooling

- CI, release and bundle-size workflows run the real build (`npm run build:ci`: `lint`, `format:check`, then tsup), including the coverage legs (`coverage_build_command`) ([#81](#81)).
- The bundle-size check measures `dist/**.mjs` / `dist/**.cjs` instead of the root entries, `src/` and `scripts/` ([#81](#81)).
- The CI and publish test matrices start at Node.js 22.22.0, the new package floor ([#81](#81)).
- vitest and `test:cjs` run with the `node-android-tv-remote-dev` condition, so the suite tests `src/`; `test:cjs` builds first and checks `dist/`. `eslint.config.mjs` moved into `.configs/` ([#81](#81)).
- `tmp/` is gitignored ([#80](#80)).

## 🧪 Tests

- `adb-client.test.vitest.mjs` mocks the adbkit client and device and drives every path that calls into adbkit: client creation, connect / disconnect, the heartbeat and connection check, auto-disconnect, key, long-press and text shell commands, `setSettings`, `ensureAwake`, `reboot`, `screencap` / thumbnail and `waitBootComplete`, plus a check that the real adbkit package still has every client, device and util method the remote calls. Line coverage of `src/lib/android-tv-remote.mjs` goes from 24% to 95% ([#84](#84)).
- `entry.test.vitest.mjs` covers `src/index.cjs` at the source level ([#81](#81)).

## 📚 Documentation

- The README states the `>=22.22.0` requirement and documents `npm run build` and the `node-android-tv-remote-dev` condition for working from a checkout ([#81](#81)).
- **NEW:** [docs/changelog/v2/v2.2.0.md](./v2.2.0.md) — this changelog.

## 🔧 Dependencies

Runtime:

- `@devicefarmer/adbkit` `^3.3.8` → `^4.0.1` (3.3.9 → 4.0.1 in the lockfile) ([#84](#84)). adbkit 4 replaces bluebird with native promises, makes cancellation explicit with `AbortSignal`, adds an `exports` map that blocks deep imports, requires Node.js 22.12 or later, and moves to `adbkit-logcat` 3 and `adbkit-monkey` 2. The remote only imports the package root, only uses `.then` / `.catch` / `await` on adbkit promises, and doesn't use trackers, sync transfers, logcat or monkey, so no source change was needed beyond passing the new `signal` to `waitBootComplete`. `bluebird` is no longer installed.
- `sharp` `^0.35.3` → `^0.35.5` (the lockfile was already on 0.35.5) ([#82](#82)).

Development only:

- `tsup` `^9.0.0` and `typescript` added with the build ([#81](#81)); `typescript` is pinned to `^6.0.3`, since TypeScript 7's JavaScript declaration emit isn't complete yet ([#83](#83)).
- `overrides` for `katex` (`>=0.19.1 <1.0.0`, 0.16.47 → 0.19.1) and `minimatch` (`^11.0.3`, 10.2.6 → 11.0.3) clear the dev-only advisories that come in through `eslint` and `@eslint/markdown` ([#83](#83)).
- Toolchain refresh ([#82](#82)): `@cldmv/configs` 1.2.4 → 1.3.0, `@cldmv/fix-headers` 2.2.0 → 2.2.4, `@cldmv/vitest-runner` 1.5.3 → 1.5.6, `vitest` / `@vitest/coverage-v8` 5.0.3 → 5.0.5, `eslint` 10.12.0 → 10.14.0, `@eslint/css` 2.0.0 → 2.0.1, `@eslint/json` 2.1.0 → 2.1.1, `globals` 17.13.0 → 17.14.0, plus transitive fixes from `npm audit fix` (`vite` 8.3.2 → 8.3.5 among them).
- `prettier` 3.9.9 → 3.9.10 ([#66](#66)).

---

## Upgrade notes

- **Node.js `>=22.22.0` is required.** Upgrade Node.js before upgrading the package. On Node.js 20, stay on [v2.1.9](./v2.1.9.md).
- `waitBootComplete()` now rejects once its timeout (60 seconds by default) passes. A caller that relied on it waiting indefinitely for a slow boot should pass a larger timeout and handle the rejection.
- `screencap-saved` and `screencap-complete` now fire after the file is on disk, and a write failure arrives as a `screencap` error. Code that worked around the early events (for example by polling for the file) can drop the workaround.
- The exported API is unchanged for both `import` and `require()`. Code that reached into `src/` or `scripts/setup-device.mjs` / `scripts/wake-tv.mjs` inside the installed package must stop doing so; those files are no longer published.



<details>
<summary>👥 Contributors</summary>

- @Shinrai

</details>

---

<!-- coverage-start -->

![coverage](https://img.shields.io/badge/coverage-93.6%25-brightgreen?style=for-the-badge&logo=vitest&logoColor=white)

| Metric | Coverage |
|--------|----------|
| Statements | 94.8% |
| Branches   | 86.6% |
| Functions  | 97.5% |
| Lines      | 95.6% |

*Avg: **93.6%** · `b8963e3` · Node lts/**

<!-- coverage-end -->

<!-- co-authors -->

Co-authored-by: Shinrai <[email protected]>
Shinrai added a commit that referenced this pull request Nov 8, 2026
# `@cldmv/node-android-tv-remote` v2.2.0 Changelog

**Release Date**: November 2026
**Release Type**: Minor
**Branch**: `release/2.2.0`

---

## Overview

Version 2.2.0 moves the package to the CLDMV library layout with a tsup build, moves the runtime dependency `@devicefarmer/adbkit` to its new major 4, and fixes two long-standing bugs: `waitBootComplete(timeout)` now actually stops waiting at its timeout, and `screencap()` with a `filepath` no longer reports the file saved before it is written.

The supported Node.js range changes: `engines.node` goes from `>=20.9.0` to `>=22.22.0`, and `@devicefarmer/adbkit` 4 itself requires Node.js 22.12 or later. That is a real requirement change even though it ships in a minor release; see [Breaking Changes](#-breaking-changes) and the upgrade notes. The exported API (`createRemote`, `createAndroidTVRemote` and the default export, from both `import` and `require()`) is unchanged.

---

## 💥 Breaking Changes

### Node.js `>=22.22.0` is now required ([#81](#81))

`engines.node` was `>=20.9.0` in v2.1.9 (set by `sharp`), with `require()` documented as needing `^20.19.0` or `>=22.12.0`. Both are now `>=22.22.0`. The new build toolchain no longer runs on Node.js 20 (tsup 9 alone declares `^22.18.0 || ^24.11.0 || >=26.0.0`), and `@devicefarmer/adbkit` 4 declares `>= 22.12`, so Node.js 20 is no longer supported at runtime either. The floor is set to 22.22.0, the oldest version the CI and publish matrices now test. The `ERR_REQUIRE_ESM` message that `require()` throws on a Node.js without `require(esm)` now names `>=22.22.0`.

npm prints an `EBADENGINE` warning when installing on an older Node.js, and the install fails when `engine-strict` is set.

### `waitBootComplete()` now rejects at its timeout ([#84](#84), fixes [#85](#85))

This is a bug fix, listed here because it changes what a caller sees. `waitBootComplete(timeout = 60000)` documented a timeout but never passed it on, so the call waited until the device finished booting, however long that took. See [Bug Fixes](#-bug-fixes) for the details.

---

## 🐛 Bug Fixes

### `waitBootComplete(timeout)` honors its timeout ([#84](#84), fixes [#85](#85))

The remote now hands adbkit 4 an `AbortSignal.timeout(timeout)`. When it fires, adbkit closes the connection and rejects with a `TimeoutError`; the remote logs the existing "Boot completion timeout after …ms" message, emits the error, and rejects. A call with no argument now gives up after the documented 60 seconds instead of waiting indefinitely.

### `screencap()` finishes writing a resized screenshot before reporting it saved ([#84](#84), fixes [#86](#86))

With a `filepath` (and optionally `width` / `height`), the background save ended the file stream and emitted `screencap-saved` and `screencap-complete` straight away, before the data reached the file, and the file stream had no `error` listener. The capture, resize and file write now run through `stream/promises` `pipeline()`: the two events fire, and `lastScreencapData` is set, only after the file is fully written. A capture, resize or write failure tears the whole pipeline down and is reported as a `screencap` error with no completion events.

---

## ✨ Features

### Library layout: `src/` entries and a tsup build ([#81](#81), fixes [#75](#75))

The hand-written root `index.mjs` / `index.cjs` moved to `src/index.mjs` / `src/index.cjs`, and `build` is now tsup (`tsup.config.mjs`) instead of an `echo` stub:

- `dist/index.mjs` is a minified ESM bundle of `src/index.mjs`, with names and `node:` specifiers kept. The keycode, keyboard and remote-key JSON tables are inlined. The runtime dependencies (`@devicefarmer/adbkit`, `sharp`) stay external.
- `dist/index.cjs` is not a second bundle. It is a verbatim copy of `src/index.cjs`, the thin wrapper that loads `./index.mjs` through Node's synchronous `require(esm)` and keeps the historical CommonJS shape (`module.exports` is `createRemote`, with `createRemote`, `createAndroidTVRemote` and `default` on it).

`main` / `module` point at `dist/`, `exports` adds `./package.json`, and `prepack` runs the build so `dist/` is never committed. The published files are now `dist/` (without source maps) and `scripts/postinstall.mjs`, which still runs on install to check for `adb`. `src/` and the other two helper scripts are no longer published: `scripts/setup-device.mjs` and `scripts/wake-tv.mjs` import `src/`, so they are checkout tools (`npm run setup-device` in a clone of this repository).

### `node-android-tv-remote-dev` export condition ([#81](#81))

The `"."` export carries a `node-android-tv-remote-dev` condition that points `import` and `require` at `src/`. In a checkout, `node --conditions=node-android-tv-remote-dev` runs the unbuilt source; without it the package resolves to `dist/`, which `npm run build` produces. Installed copies only ship `dist/`.

---

## 🔧 CI & tooling

- CI, release and bundle-size workflows run the real build (`npm run build:ci`: `lint`, `format:check`, then tsup), including the coverage legs (`coverage_build_command`) ([#81](#81)).
- The bundle-size check measures `dist/**.mjs` / `dist/**.cjs` instead of the root entries, `src/` and `scripts/` ([#81](#81)).
- The CI and publish test matrices start at Node.js 22.22.0, the new package floor ([#81](#81)).
- vitest and `test:cjs` run with the `node-android-tv-remote-dev` condition, so the suite tests `src/`; `test:cjs` builds first and checks `dist/`. `eslint.config.mjs` moved into `.configs/` ([#81](#81)).
- `tmp/` is gitignored ([#80](#80)).

## 🧪 Tests

- `adb-client.test.vitest.mjs` mocks the adbkit client and device and drives every path that calls into adbkit: client creation, connect / disconnect, the heartbeat and connection check, auto-disconnect, key, long-press and text shell commands, `setSettings`, `ensureAwake`, `reboot`, `screencap` / thumbnail and `waitBootComplete`, plus a check that the real adbkit package still has every client, device and util method the remote calls. Line coverage of `src/lib/android-tv-remote.mjs` goes from 24% to 95% ([#84](#84)).
- `entry.test.vitest.mjs` covers `src/index.cjs` at the source level ([#81](#81)).

## 📚 Documentation

- The README states the `>=22.22.0` requirement and documents `npm run build` and the `node-android-tv-remote-dev` condition for working from a checkout ([#81](#81)).
- **NEW:** [docs/changelog/v2/v2.2.0.md](./v2.2.0.md) — this changelog.

## 🔧 Dependencies

Runtime:

- `@devicefarmer/adbkit` `^3.3.8` → `^4.0.1` (3.3.9 → 4.0.1 in the lockfile) ([#84](#84)). adbkit 4 replaces bluebird with native promises, makes cancellation explicit with `AbortSignal`, adds an `exports` map that blocks deep imports, requires Node.js 22.12 or later, and moves to `adbkit-logcat` 3 and `adbkit-monkey` 2. The remote only imports the package root, only uses `.then` / `.catch` / `await` on adbkit promises, and doesn't use trackers, sync transfers, logcat or monkey, so no source change was needed beyond passing the new `signal` to `waitBootComplete`. `bluebird` is no longer installed.
- `sharp` `^0.35.3` → `^0.35.5` (the lockfile was already on 0.35.5) ([#82](#82)).

Development only:

- `tsup` `^9.0.0` and `typescript` added with the build ([#81](#81)); `typescript` is pinned to `^6.0.3`, since TypeScript 7's JavaScript declaration emit isn't complete yet ([#83](#83)).
- `overrides` for `katex` (`>=0.19.1 <1.0.0`, 0.16.47 → 0.19.1) and `minimatch` (`^11.0.3`, 10.2.6 → 11.0.3) clear the dev-only advisories that come in through `eslint` and `@eslint/markdown` ([#83](#83)).
- Toolchain refresh ([#82](#82)): `@cldmv/configs` 1.2.4 → 1.3.0, `@cldmv/fix-headers` 2.2.0 → 2.2.4, `@cldmv/vitest-runner` 1.5.3 → 1.5.6, `vitest` / `@vitest/coverage-v8` 5.0.3 → 5.0.5, `eslint` 10.12.0 → 10.14.0, `@eslint/css` 2.0.0 → 2.0.1, `@eslint/json` 2.1.0 → 2.1.1, `globals` 17.13.0 → 17.14.0, plus transitive fixes from `npm audit fix` (`vite` 8.3.2 → 8.3.5 among them).
- `prettier` 3.9.9 → 3.9.10 ([#66](#66)).

---

## Upgrade notes

- **Node.js `>=22.22.0` is required.** Upgrade Node.js before upgrading the package. On Node.js 20, stay on [v2.1.9](./v2.1.9.md).
- `waitBootComplete()` now rejects once its timeout (60 seconds by default) passes. A caller that relied on it waiting indefinitely for a slow boot should pass a larger timeout and handle the rejection.
- `screencap-saved` and `screencap-complete` now fire after the file is on disk, and a write failure arrives as a `screencap` error. Code that worked around the early events (for example by polling for the file) can drop the workaround.
- The exported API is unchanged for both `import` and `require()`. Code that reached into `src/` or `scripts/setup-device.mjs` / `scripts/wake-tv.mjs` inside the installed package must stop doing so; those files are no longer published.



<details>
<summary>👥 Contributors</summary>

- @Shinrai

</details>

---

<!-- coverage-start -->

![coverage](https://img.shields.io/badge/coverage-93.6%25-brightgreen?style=for-the-badge&logo=vitest&logoColor=white)

| Metric | Coverage |
|--------|----------|
| Statements | 94.8% |
| Branches   | 86.6% |
| Functions  | 97.5% |
| Lines      | 95.6% |

*Avg: **93.6%** · `b8963e3` · Node lts/**

<!-- coverage-end -->

<!-- co-authors -->

Co-authored-by: Shinrai <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area: core Touches core library / runtime source code area: tests Touches test files, fixtures, or test infrastructure ! deps → next v4 flow: deps contributor PR targeting the next integration branch type: dependencies Relates to dependency updates, version bumps, or package management

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant