You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.md
+65-11Lines changed: 65 additions & 11 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -32,15 +32,49 @@ const result = await client.invokeMethod({
32
32
awaitclient.revokeSession();
33
33
```
34
34
35
-
### Configuring Transport Timeout
35
+
### Configuring Transport Timeouts
36
36
37
-
You can configure a default timeout (in milliseconds) for all requests made through the transport by passing the `defaultTimeout` option to `getDefaultTransport`:
37
+
#### Default Request Timeout
38
+
39
+
By default, the transport has **no timeout** (`-1`) for requests. This is because most operations require user interaction (e.g., confirming transactions in the MetaMask extension), and we don't want to prematurely cancel requests while the user is reviewing them.
40
+
41
+
However, you can configure a default timeout (in milliseconds) for all requests by passing the `defaultTimeout` option:
42
+
43
+
```typescript
44
+
const transport =getDefaultTransport({ defaultTimeout: 30000 }); // 30 seconds timeout for all requests
45
+
const client =getMultichainClient({ transport });
46
+
```
47
+
48
+
To explicitly disable timeouts (wait indefinitely), set the timeout to `-1`:
49
+
50
+
```typescript
51
+
const transport =getDefaultTransport({ defaultTimeout: -1 }); // No timeout (default behavior)
52
+
```
53
+
54
+
#### Warmup Timeout
55
+
56
+
The `warmupTimeout` is a special timeout used specifically for the **first request** sent immediately after the transport establishes its connection. This is useful because:
57
+
58
+
- Some transports need a brief moment to fully initialize before they can reliably process requests
59
+
- The initial "warmup" request is typically a lightweight check (e.g., `wallet_getSession`) that doesn't require user interaction
60
+
- This timeout is usually much shorter than the regular request timeout
38
61
39
62
```typescript
40
-
const transport =getDefaultTransport({ defaultTimeout: 5000 }); // 5 seconds timeout for all requests
63
+
const transport =getDefaultTransport({
64
+
warmupTimeout: 200, // 200 ms for the initial warmup request
65
+
defaultTimeout: -1// No timeout for subsequent requests (user interactions)
66
+
});
41
67
const client =getMultichainClient({ transport });
42
68
```
43
69
70
+
**Key differences between `warmupTimeout` and `defaultTimeout`:**
71
+
72
+
| Property | Purpose | Typical Value | When Applied |
// Use withRetry to handle the case where the Multichain API requests don't resolve on page load (cf. https://github.com/MetaMask/metamask-mobile/issues/16550)
0 commit comments