Better error message when calling `BaseProvider.request()` without `params`?
Nobody has claimed this yet.
Assessment
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Newbie friendliness
- 35/100
- Issue type
- Bug
- Clarity
- Mostly clear
- Activity status
- Stale
- Tech stack
- typescript
- Domain
- api
Research direction
Start in src/BaseProvider.ts at the BaseProvider.request method linked in the issue, and reproduce the two window.ethereum.request examples to compare omitted params with params: []. Trace where the undefined length error is produced. Done means the no-params call has intentional, user-facing behavior rather than the confusing TypeError, with the chosen behavior reflected in coverage.
Written by the indexing model from the issue text.
Description
Environment:
Brave browser with MetaMask v9.8.4 extension installed. Running code in console
The following fails with a confusing error: MetaMask - RPC Error: Cannot read property 'length' of undefined
window.ethereum
.request({
method: "eth_blockNumber",
})
However, this succeeds:
window.ethereum
.request({
method: "eth_blockNumber",
params: [],
})
Some methods like ethereum.request({ method: "eth_requestAccounts" }) don't require params to be set, so I spent an embarrassing of time trying to find out why one call worked and the other didn't.
Context:
I was trying to figure out why a convenience library was failing and figured that going down a level down to the RPC level might help. I tried the most basic RPC request I could think of (getting block number) when I got this error.
Possible solutions:
- One solution might be for the MetaMask to add
params: []when no params are specified. - Another solution might be to add some more error checking to the BaseProvider
requestmethod?
- Dominant language
- TypeScript
- Stars
- 268
- Forks
- 130
- PR merge metrics
- No merged PRs in 30d
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from MetaMask/providers
-
Difficulty 4/5 3-5 days Newbie friendliness 38/100
-
Difficulty 4/5 3-5 days Newbie friendliness 42/100
-
Difficulty 3/5 1-2 days Newbie friendliness 25/100
-
Difficulty 1/5 Under an hour Newbie friendliness 58/100
-
Difficulty 3/5 1-2 days Newbie friendliness 35/100
All issues in MetaMask/providers
Similar issues
-
Difficulty 2/5 1-3 hours Newbie friendliness 84/100
Eynzof/Hermes-CN-Desktop#610 ·
-
bug clawsweeper:linked-pr-open clawsweeper:needs-live-repro clawsweeper:no-new-fix-pr impact:message-loss issue-rating: 🐚 platinum hermit P2 regression
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
-
enhancement
Difficulty 2/5 1-3 hours Newbie friendliness 68/100
-
calcite-components needs triage refactor
Difficulty 2/5 1-3 hours Newbie friendliness 75/100
Esri/calcite-design-system#15203 ·
-
Difficulty 1/5 Under an hour Newbie friendliness 78/100
fullcalendar/fullcalendar#8106 ·