diff --git a/lib/actions/api.js b/lib/actions/api.js index 77be3becd..64c0d94dd 100644 --- a/lib/actions/api.js +++ b/lib/actions/api.js @@ -337,6 +337,9 @@ query stopQuery($stopId: [String]) { findStopResponse, findStopError, { + // find stop should not be throttled since it can make quite frequent + // updates when fetching stop times for a stop + noThrottle: true, serviceId: 'stops', rewritePayload: (payload) => { // convert pattern array to ID-mapped object @@ -715,17 +718,19 @@ function createQueryAction (endpoint, responseAction, errorAction, options = {}) url = `${api.host}${api.port ? ':' + api.port : ''}${api.path}/${endpoint}` } - // don't make a request to a URL that has already seen the same request - // within the last 10 seconds - const throttleKey = options.fetchOptions - ? `${url}-${hashObject(options.fetchOptions)}` - : url - if (throttledUrls[throttleKey] && throttledUrls[throttleKey] > now() - TEN_SECONDS) { - // URL already had a request within last 10 seconds, warn and exit - console.warn(`Request throttled for url: ${url}`) - return - } else { - throttledUrls[throttleKey] = now() + if (!options.noThrottle) { + // don't make a request to a URL that has already seen the same request + // within the last 10 seconds + const throttleKey = options.fetchOptions + ? `${url}-${hashObject(options.fetchOptions)}` + : url + if (throttledUrls[throttleKey] && throttledUrls[throttleKey] > now() - TEN_SECONDS) { + // URL already had a request within last 10 seconds, warn and exit + console.warn(`Request throttled for url: ${url}`) + return + } else { + throttledUrls[throttleKey] = now() + } } let payload try {