Skip to content

Commit ed1b367

Browse files
valueofmax-ipinfo
authored andcommitted
Reject on timeout in lookupIP, lookupASN, and getMap
Node HTTP libraries don't end the request when timeout is reached. They simply publish a new event, timeout, which needs to be handled by the client. The getBatch function was already handling timeouts but other methods weren't.
1 parent 61bd936 commit ed1b367

File tree

1 file changed

+12
-0
lines changed

1 file changed

+12
-0
lines changed

src/ipinfoWrapper.ts

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -179,6 +179,10 @@ export default class IPinfoWrapper {
179179
}
180180
});
181181

182+
req.on("timeout", () => {
183+
reject(new Error("timeout reached"));
184+
});
185+
182186
req.on("error", (error) => {
183187
reject(error);
184188
});
@@ -258,6 +262,10 @@ export default class IPinfoWrapper {
258262
}
259263
});
260264

265+
req.on("timeout", () => {
266+
reject(new Error("timeout reached"));
267+
});
268+
261269
req.on("error", (error) => {
262270
reject(error);
263271
});
@@ -327,6 +335,10 @@ export default class IPinfoWrapper {
327335
}
328336
});
329337

338+
req.on("timeout", () => {
339+
reject(new Error("timeout reached"));
340+
});
341+
330342
req.on("error", (error) => {
331343
reject(error);
332344
});

0 commit comments

Comments
 (0)