Skip to content

fix(cdp-client): type-only emitter cast for Page.loadEventFired race#22

Open
sergei-aronsen wants to merge 1 commit into
RapierCraft:mainfrom
sergei-aronsen:fix/cdp-load-event-types
Open

fix(cdp-client): type-only emitter cast for Page.loadEventFired race#22
sergei-aronsen wants to merge 1 commit into
RapierCraft:mainfrom
sergei-aronsen:fix/cdp-load-event-types

Conversation

@sergei-aronsen
Copy link
Copy Markdown

Summary

Main currently fails tsc with:

```
src/cdp-client.ts(1394,22): error TS2339: Property 'removeListener' does not exist on type 'Client'.
src/cdp-client.ts(1397,20): error TS2339: Property 'once' does not exist on type 'Client'.
```

Introduced by #18 (ebf055e). The CRI `Client` is an EventEmitter at runtime, but `@types/chrome-remote-interface` only declares `on(...)` — not `once`/`removeListener`. Build fails on every PR until this lands.

Fix

Locally-scoped EventEmitter-shaped interface + a single as unknown as ... cast. No runtime change.

Why it matters

CI is red on main, which means every open PR (#14, #15, #17, #20) is also red regardless of its own correctness. This unblocks all four.

Test plan

  • npm run test:unit (55/55 pass locally)
  • npx tsc --noEmit clean

🤖 Generated with Claude Code

`navigateWithRetry` subscribes to `Page.loadEventFired` via
`client.once` and removes the listener via `client.removeListener` if
the timeout branch wins. The CRI Client is an EventEmitter at runtime
so both methods exist, but @types/chrome-remote-interface@^0.34.x
only declares `on(...)`. tsc therefore rejected this file with:

  src/cdp-client.ts(1394,22): error TS2339: Property 'removeListener'
    does not exist on type 'Client'.
  src/cdp-client.ts(1397,20): error TS2339: Property 'once'
    does not exist on type 'Client'.

The error is real — it broke the build on main itself, blocking every
in-flight PR from passing CI. Fix: a minimal locally-scoped
EventEmitter-shaped interface and a single `as unknown as ...` cast.
No runtime change.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
@sergei-aronsen
Copy link
Copy Markdown
Author

Heads-up: this PR unblocks four others that are mergeable but red on CI for the same tsc error:

Suggested merge order: this PR first, then the rebased four. Once this lands, hitting "Update branch" on each (or I can force-push an empty rebase to re-trigger CI) flips them green.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant