Skip to content

Commit

Permalink
fix: timeout not passed to default arguments
Browse files Browse the repository at this point in the history
  • Loading branch information
TheGreatRefrigerator committed Jul 31, 2024
1 parent c5b0097 commit 60ce10d
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 60ce10d

Please sign in to comment.