Skip to content

Commit 9e10f35

Browse files
authored
Merge pull request #67 from opentripplanner/stop-time-no-throttle
Don't throttle stop time update requests
2 parents 42ddb83 + 813df5a commit 9e10f35

File tree

1 file changed

+16
-11
lines changed

1 file changed

+16
-11
lines changed

Diff for: lib/actions/api.js

+16-11
Original file line numberDiff line numberDiff line change
@@ -337,6 +337,9 @@ query stopQuery($stopId: [String]) {
337337
findStopResponse,
338338
findStopError,
339339
{
340+
// find stop should not be throttled since it can make quite frequent
341+
// updates when fetching stop times for a stop
342+
noThrottle: true,
340343
serviceId: 'stops',
341344
rewritePayload: (payload) => {
342345
// convert pattern array to ID-mapped object
@@ -715,17 +718,19 @@ function createQueryAction (endpoint, responseAction, errorAction, options = {})
715718
url = `${api.host}${api.port ? ':' + api.port : ''}${api.path}/${endpoint}`
716719
}
717720

718-
// don't make a request to a URL that has already seen the same request
719-
// within the last 10 seconds
720-
const throttleKey = options.fetchOptions
721-
? `${url}-${hashObject(options.fetchOptions)}`
722-
: url
723-
if (throttledUrls[throttleKey] && throttledUrls[throttleKey] > now() - TEN_SECONDS) {
724-
// URL already had a request within last 10 seconds, warn and exit
725-
console.warn(`Request throttled for url: ${url}`)
726-
return
727-
} else {
728-
throttledUrls[throttleKey] = now()
721+
if (!options.noThrottle) {
722+
// don't make a request to a URL that has already seen the same request
723+
// within the last 10 seconds
724+
const throttleKey = options.fetchOptions
725+
? `${url}-${hashObject(options.fetchOptions)}`
726+
: url
727+
if (throttledUrls[throttleKey] && throttledUrls[throttleKey] > now() - TEN_SECONDS) {
728+
// URL already had a request within last 10 seconds, warn and exit
729+
console.warn(`Request throttled for url: ${url}`)
730+
return
731+
} else {
732+
throttledUrls[throttleKey] = now()
733+
}
729734
}
730735
let payload
731736
try {

0 commit comments

Comments
 (0)