MetaMask / MetaMask/core

PollingController.startPollingByNetworkClientId does not type-check the given options

Open
#3,634 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

bug team-wallet-framework wf-bugs
Dominant language
TypeScript
Stars
413
Forks
308
Avg merge
1d 4h
Merged PRs (30d)
253

Description

When calling `startPollingByNetworkClientId` in a controller that inherits from PollingController, it is possible to not pass any `options` or the wrong `options`, even if types are supplied for those `options` in that controller's `_executePoll`. Since `startPollingByNetworkClientId` is contained with PollingController, and PollingController has no awareness of what a subclass needs, all it can say is that the `options` are optional, and if they are supplied, they must be `Json`. The result of this is that if options are missing from `startPollingByNetworkClientId`, it can cause errors at runtime, which is not only undesirable because it goes against the purpose of using TypeScript, but also because it it is confusing to consumers.

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by locating PollingController and the subclass _executePoll declarations, then trace how startPollingByNetworkClientId types its options. Determine how the controller can preserve the subclass's required options and add compile-time coverage for missing and incorrect options. Done means invalid calls are rejected while valid subclass calls remain type-safe.

Written by the indexing model from the issue text.

Assessment

Tech stack
typescript
Domain
backend-api-design
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.