Skip to content

eth/mobile: native crash on Android – unhashable type rpc.HTTPError #25049

@enginegl

Description

@enginegl

System information

Geth version: 1.10.17
OS & Version: Android 12

Expected behaviour

BoundContract.call() throws Java exception on Android when RPC network response has an error code (<200, >=300 according to rpc/http.go). Android app developer should be able to handle this exception.

Actual behaviour

Android application closes because of the native crash from Go side. This crash cannot be handled by an application developer.

Steps to reproduce the behaviour

In my case I have a free alchemy.com account with a RPS limit.

When I make calls too fast, alchemy returns error 429 Your app has exceeded its compute units per second capacity. If you have retries enabled, you can safely ignore this message. If not, check out https://docs.alchemyapi.io/guides/rate-limits

Every time alchemy returns http error, application crashes.

The problem is HTTPError cannot be used as a map key here: https://github.com/golang/mobile/blob/master/bind/seq/ref.go#L66

Backtrace

panic: runtime error: hash of unhashable type rpc.HTTPError
goroutine 262 [running, locked to thread]:
golang.org/x/mobile/bind/seq.ToRefNum({0x736913da80?, 0x4000098750})
	/var/folders/bb/06fzqqwn1554b7d965nl2kvw0000gn/T/gomobile-work-1747544557/pkg/mod/golang.org/x/[email protected]/bind/seq/ref.go:66 +0xe0
main.proxygeth_BoundContract_Call(0x8e000?, 0x40?, 0x0?, {0x74976611a0, 0x9, {0x0, 0x0, 0x0, 0x0}}, 0x0?)
	/private/var/folders/bb/06fzqqwn1554b7d965nl2kvw0000gn/T/gomobile-work-1747544557/src/gobind/go_gethmain.go:771 +0x10c

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions