Skip to content

Commit b4d792f

Browse files
authored
fix: RPC request with id already seen error when using firefox (#91)
1 parent aeb6e05 commit b4d792f

File tree

2 files changed

+5
-2
lines changed

2 files changed

+5
-2
lines changed

CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,10 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
77

88
## [Unreleased]
99

10+
### Fixed
11+
12+
- fix: make sure `getUniqueId` is called on each `windowPostMessageTransport` request to avoid `RPC request with id already seen.` error on extension when using firefox ([#91](https://github.com/MetaMask/multichain-api-client/pull/91))
13+
1014
## [0.10.0]
1115

1216
### Added

src/transports/windowPostMessageTransport.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,6 @@ export function getWindowPostMessageTransport(
2828
const { defaultTimeout = DEFAULT_REQUEST_TIMEOUT, warmupTimeout = DEFAULT_WARMUP_TIMEOUT } = params;
2929
let messageListener: ((event: MessageEvent) => void) | null = null;
3030
const pendingRequests: Map<number, (value: any) => void> = new Map();
31-
let requestId = getUniqueId();
3231
/**
3332
* Storing notification callbacks.
3433
* If we detect a "notification" (a message without an id) coming from the extension, we'll call each callback in here.
@@ -115,7 +114,7 @@ export function getWindowPostMessageTransport(
115114
throw new TransportError('Transport not connected');
116115
}
117116

118-
const id = requestId++;
117+
const id = getUniqueId();
119118
const request = {
120119
jsonrpc: '2.0' as const,
121120
id,

0 commit comments

Comments
 (0)