• Sean Hammond's avatar
    Cache access token request promises · dbcb5881
    Sean Hammond authored
    Cache the access token request promise, not just the access token
    itself.
    
    This commit fixes a problem that the client would send multiple concurrent
    access token requests if tokenGetter() was called multiple times before
    a response to any of the HTTP requests was received:
    
    1. tokenGetter() is called, sends an HTTP request for the access token
       and returns a Promise for the access token from the request's response
    
    2. Before the HTTP response is received tokenGetter() is called again,
       sends another HTTP request, returns another Promise.
    
    As soon as one access token response is received then tokenGetter()
    caches the access token and just returns it, doesn't send any more HTTP
    requests, but each time tokenGetter() is called *before the first access
    token response has been received* it sends another, concurrent access
    token request. It does not "know" that it already has an access token
    request in-flight.
    
    The fix is to cache the first access token request Promise when the first
    access token request is sent and then just keep returning that Promise, instead
    of sending more requests:
    
    Instead of caching the access token itself (`cachedToken`) we now cache
    a Promise for the access token (`accessTokenPromise`) the first
    time we send the access token request.
    
    Each further time that `tokenGetter()` is called, if it already has a
    `accessTokenPromise`, then it just returns the Promise and doesn't
    send another HTTP request. It now "knows" that it already has an access
    token request in-flight.
    dbcb5881
Name
Last commit
Last update
..
integration Loading commit data...
analytics-test.js Loading commit data...
annotation-fixtures.js Loading commit data...
annotation-mapper-test.js Loading commit data...
annotation-metadata-test.js Loading commit data...
annotation-ui-test.js Loading commit data...
annotation-viewer-controller-test.js Loading commit data...
app-controller-test.js Loading commit data...
auth-test.js Loading commit data...
bootstrap.js Loading commit data...
build-thread-test.js Loading commit data...
drafts-test.js Loading commit data...
fake-redux-store.js Loading commit data...
features-test.js Loading commit data...
form-respond-test.coffee Loading commit data...
frame-sync-test.js Loading commit data...
groups-test.js Loading commit data...
host-config-test.js Loading commit data...
host-test.coffee Loading commit data...
local-storage-test.coffee Loading commit data...
login-form-test.coffee Loading commit data...
markdown-commands-test.js Loading commit data...
media-embedder-test.js Loading commit data...
oauth-auth-test.js Loading commit data...
permissions-test.coffee Loading commit data...
raven-test.js Loading commit data...
render-markdown-test.js Loading commit data...
retry-util-test.js Loading commit data...
root-thread-test.js Loading commit data...
search-client-test.js Loading commit data...
search-filter-test.coffee Loading commit data...
service-url-test.js Loading commit data...
session-test.js Loading commit data...
store-test.js Loading commit data...
stream-controller-test.coffee Loading commit data...
streamer-test.js Loading commit data...
tabs-test.js Loading commit data...
tags-test.coffee Loading commit data...
time-test.js Loading commit data...
unicode-test.coffee Loading commit data...
view-filter-test.coffee Loading commit data...
virtual-thread-list-test.js Loading commit data...
websocket-test.js Loading commit data...
widget-controller-test.js Loading commit data...