Skip to content

Commit 6f15b96

Browse files
Merge pull request #86 from GIScience/fix/timeout-not-passed-correctly
fix: timeout not passed to default arguments
2 parents c5b0097 + 60ce10d commit 6f15b96

File tree

2 files changed

+5
-3
lines changed

2 files changed

+5
-3
lines changed

src/OrsBase.js

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,14 +25,16 @@ class OrsBase {
2525
if (args[Constants.propNames.service]) {
2626
this.defaultArgs[Constants.propNames.service] = args[Constants.propNames.service]
2727
}
28+
if (args[Constants.propNames.timeout]) {
29+
this.defaultArgs[Constants.propNames.timeout] = args[Constants.propNames.timeout]
30+
}
2831
if (Constants.propNames.apiKey in args) {
2932
this.defaultArgs[Constants.propNames.apiKey] = args[Constants.propNames.apiKey]
3033
} else if (!args[Constants.propNames.host]) {
3134
// Do not error if a host is specified; useful for locally-run instances of ORS
3235
console.error(Constants.missingAPIKeyMsg)
3336
throw new Error(Constants.missingAPIKeyMsg)
3437
}
35-
3638
}
3739

3840
checkHeaders() {
@@ -65,7 +67,7 @@ class OrsBase {
6567

6668
async createRequest(body) {
6769
const controller = new AbortController()
68-
const timeout = setTimeout(() => controller.abort('timed out'), this.defaultArgs[Constants.propNames.timeout] || 5000)
70+
const timeout = setTimeout(() => controller.abort(), this.defaultArgs[Constants.propNames.timeout] || 5000)
6971

7072
try {
7173
const orsResponse = await this.fetchRequest(body, controller)

src/OrsGeocode.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -129,7 +129,7 @@ class OrsGeocode extends OrsBase {
129129

130130
async geocodePromise() {
131131
const controller = new AbortController()
132-
const timeout = setTimeout(() => controller.abort('timed out'), this.defaultArgs[Constants.propNames.timeout] || 5000)
132+
const timeout = setTimeout(() => controller.abort(), this.defaultArgs[Constants.propNames.timeout] || 5000)
133133

134134
try {
135135
const orsResponse = await this.fetchGetRequest(controller)

0 commit comments

Comments
 (0)