Skip to content

Commit

Permalink
Merge pull request #86 from GIScience/fix/timeout-not-passed-correctly
Browse files Browse the repository at this point in the history
fix: timeout not passed to default arguments
  • Loading branch information
TheGreatRefrigerator committed Jul 31, 2024
2 parents c5b0097 + 60ce10d commit 6f15b96
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 3 deletions.
6 changes: 4 additions & 2 deletions src/OrsBase.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,14 +25,16 @@ class OrsBase {
if (args[Constants.propNames.service]) {
this.defaultArgs[Constants.propNames.service] = args[Constants.propNames.service]
}
if (args[Constants.propNames.timeout]) {
this.defaultArgs[Constants.propNames.timeout] = args[Constants.propNames.timeout]
}
if (Constants.propNames.apiKey in args) {
this.defaultArgs[Constants.propNames.apiKey] = args[Constants.propNames.apiKey]
} else if (!args[Constants.propNames.host]) {
// Do not error if a host is specified; useful for locally-run instances of ORS
console.error(Constants.missingAPIKeyMsg)
throw new Error(Constants.missingAPIKeyMsg)
}

}

checkHeaders() {
Expand Down Expand Up @@ -65,7 +67,7 @@ class OrsBase {

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

try {
const orsResponse = await this.fetchRequest(body, controller)
Expand Down
2 changes: 1 addition & 1 deletion src/OrsGeocode.js
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,7 @@ class OrsGeocode extends OrsBase {

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

try {
const orsResponse = await this.fetchGetRequest(controller)
Expand Down

0 comments on commit 6f15b96

Please sign in to comment.