Skip to content

Commit 693094e

Browse files
committed
More debug information in timeout and fetch errors (ethers-io#678).
1 parent 5e7d28b commit 693094e

File tree

1 file changed

+16
-2
lines changed

1 file changed

+16
-2
lines changed

packages/web/src.ts/index.ts

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -122,7 +122,12 @@ export function fetchJson(connection: string | ConnectionInfo, json?: string, pr
122122
if (timer == null) { return; }
123123
timer = null;
124124

125-
reject(logger.makeError("timeout", Logger.errors.TIMEOUT, { timeout: timeout }));
125+
reject(logger.makeError("timeout", Logger.errors.TIMEOUT, {
126+
requestBody: (options.body || null),
127+
requestMethod: options.method,
128+
timeout: timeout,
129+
url: url
130+
}));
126131
}, timeout);
127132
}
128133
});
@@ -146,6 +151,8 @@ export function fetchJson(connection: string | ConnectionInfo, json?: string, pr
146151
if (response == null) {
147152
runningTimeout.cancel();
148153
logger.throwError("missing response", Logger.errors.SERVER_ERROR, {
154+
requestBody: (options.body || null),
155+
requestMethod: options.method,
149156
serverError: error,
150157
url: url
151158
});
@@ -164,6 +171,8 @@ export function fetchJson(connection: string | ConnectionInfo, json?: string, pr
164171
status: response.statusCode,
165172
headers: response.headers,
166173
body: body,
174+
requestBody: (options.body || null),
175+
requestMethod: options.method,
167176
url: url
168177
});
169178
}
@@ -178,6 +187,8 @@ export function fetchJson(connection: string | ConnectionInfo, json?: string, pr
178187
logger.throwError("invalid JSON", Logger.errors.SERVER_ERROR, {
179188
body: body,
180189
error: error,
190+
requestBody: (options.body || null),
191+
requestMethod: options.method,
181192
url: url
182193
});
183194
}
@@ -189,7 +200,10 @@ export function fetchJson(connection: string | ConnectionInfo, json?: string, pr
189200
} catch (error) {
190201
logger.throwError("processing response error", Logger.errors.SERVER_ERROR, {
191202
body: json,
192-
error: error
203+
error: error,
204+
requestBody: (options.body || null),
205+
requestMethod: options.method,
206+
url: url
193207
});
194208
}
195209
}

0 commit comments

Comments
 (0)