Skip to content

docs(readme): an error listener is optional - #48

Merged
Shinrai merged 1 commit into
nextfrom
docs/readme-error-listener
Oct 4, 2026
Merged

Shinrai merged 1 commit into
nextfrom
docs/readme-error-listener

Conversation

@cldmv-bot

@cldmv-bot cldmv-bot Bot commented Oct 4, 2026

Copy link
Copy Markdown
Contributor

🚀 What's Changed

💥 Breaking Changes

No breaking changes

✨ Features

No new features

🐛 Bug Fixes

No bug fixes

📦 Dependencies

No dependency updates

🔧 Other Changes

  • docs(readme): an error listener is optional (3707a61)
👥 Contributors

@cldmv-bot cldmv-bot Bot added ! docs → next v4 flow: docs contributor PR targeting the next integration branch type: documentation Relates to docs, README updates, guides, or inline code comments labels Oct 4, 2026
@Shinrai
Shinrai merged commit 1b7271b into next Oct 4, 2026
31 checks passed
@cldmv-bot
cldmv-bot Bot deleted the docs/readme-error-listener branch October 4, 2026 01:31
cldmv-bot Bot added a commit that referenced this pull request Oct 5, 2026
# @cldmv/node-android-tv-remote v2.1.8 Changelog

**Release Date**: October 2026
**Release Type**: Patch
**Branch**: `release/2.1.8`

---

## Overview

Version 2.1.8 makes remotes independent of each other and stops an unheard `error` event from crashing the process. Each remote now has its own event emitter, so two TVs no longer see each other's events. When no `error` listener is attached, an error is logged instead of thrown, and the failing call still reports it. It also restores `npm run setup-device`, which had been broken since v2.1.0, and relicenses the package under Apache-2.0. The dev tooling for file headers moves to `@cldmv/fix-headers` 2.2.0 and `@cldmv/configs` 1.2.4.

---

## 🐛 Bug Fixes

### Each remote has its own event emitter ([#46](#46), fixes [#43](#43))

The event emitter and its helper functions were created once at module level and shared by every remote returned by `createRemote()`. With two TVs, listeners on one remote received the other remote's connect, disconnect, log and error events, and `off()` on one affected the other. Every remote now gets its own emitter.

### An `error` with no listener no longer crashes the process ([#46](#46), fixes [#44](#44))

The remote is an event emitter, and Node.js throws when `error` is emitted with no listener. Even a failed auto-connect inside `createRemote()`, before the caller could attach a listener, crashed the process. Now `error` is emitted only when a listener is attached. Otherwise the error goes out as a `log` event with level `"error"` (the `Error` is in `data.error`) and to `NODE_DEBUG=android-tv-remote`. The failing call still reports it: commands reject and `initPromise` rejects. A failed auto-connect is no longer an unhandled promise rejection for callers who never await `initPromise`. `connect()` and `disconnect()` still resolve with the `Error` rather than rejecting, as before.

### `npm run setup-device` works again ([#45](#45), fixes [#42](#42))

`scripts/setup-device.mjs` imported `src/lib/adb/setup.mjs`, which was deleted in v2.1.0, so the script failed with a module-not-found error, and it was still published. It now runs the setup steps through the v2 remote: connect, apply the keep-awake settings with `setSettings`, wake the device with `ensureAwake`, go to the home screen, and always disconnect, even when a step fails. All three scripts in `scripts/` now run their command only when executed directly and export `main()`, so importing them has no side effects.

---

## 📄 License

The package is relicensed from MIT to Apache-2.0 ([#41](#41)). The repository now has a `LICENSE` file; before this it had none, although `package.json` declared MIT.

---

## 🧪 Tests

- `tests/scripts.test.vitest.mjs` imports every file under `scripts/`, so a dangling import fails CI, and tests the setup flow against a fake remote.
- `tests/events.test.vitest.mjs` mocks `@devicefarmer/adbkit`, so no real ADB or network connections are made. It checks that two remotes are independent, and that errors with and without a listener are reported correctly for `connect`, `keyboard.key` and auto-connect.
- Line coverage rises from about 13% to about 23%.

---

## 📚 Documentation

- **NEW:** [docs/changelog/v2/v2.1.8.md](./v2.1.8.md): this changelog.
- **NEW:** changelog files for every earlier release, v1.0.0 through v2.1.7, under [docs/changelog/](../) ([#41](#41)).
- README restructured to the CLDMV layout: badges, What's New, Installation with Node.js requirements, Documentation index and Links ([#41](#41)). It also fixes the install and import examples, which used the wrong package name (`android-tv-remote`).
- The README now says an `error` listener is optional and describes where unheard errors go ([#48](#48)).

---

## 🔧 Dependencies

Both are dev dependencies and affect only the `npm run fix:headers` script, which extends `@cldmv/configs/fix-headers.json`. Only `package.json` and the lockfile changed; no file headers were restamped and the published package is unaffected.

- `@cldmv/fix-headers` `^2.1.1` → `^2.2.0`, in two steps. 2.1.4 ([#50](#50)) no longer writes a JavaScript comment into JSON or Markdown files, processes every repeated `--input`, and never walks dependency folders such as `node_modules`. 2.2.0 ([#52](#52)) makes `@Last modified by` follow edits to a file's content only, so a run that merely rewrites a header keeps the recorded editor.
- `@cldmv/configs` `^1.2.0` → `^1.2.4` ([#52](#52)). The shared fix-headers config now sets `forceAuthorUpdate` and `forceLastModifiedAuthorUpdate` to `false`, so `@Author` keeps the file's creator and `@Last modified by` changes only with real content edits. The 1.2.1 and 1.2.2 releases of that package only changed its own CI.

---

## Upgrade notes

- No breaking changes: drop-in for [v2.1.7](./v2.1.7.md).
- If you ran several remotes and relied on one remote's listeners also receiving another remote's events, that was the bug fixed here; attach listeners to each remote.
- Code that kept the process alive only because an unheard `error` crashed it no longer crashes: listen for `error`, or for `log` events with level `"error"`, if you want to act on failures without awaiting the call.
- The license is now Apache-2.0.



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

- @Shinrai

</details>

---

<!-- coverage-start -->

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

| Metric | Coverage |
|--------|----------|
| Statements | 23.2% |
| Branches   | 20.3% |
| Functions  | 40.6% |
| Lines      | 23.7% |

*Avg: **26.9%** · `f5dcd8f` · Node lts/**

<!-- coverage-end -->

<!-- co-authors -->

Co-authored-by: Shinrai <Shinrai@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

! docs → next v4 flow: docs contributor PR targeting the next integration branch type: documentation Relates to docs, README updates, guides, or inline code comments

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant