From 666d606914b414887dc9227db03ce379a14d5ab6 Mon Sep 17 00:00:00 2001 From: Mark Rowe Date: Wed, 27 Sep 2017 13:52:14 -0700 Subject: [PATCH] Specify a timeout when making the HTTP request to refresh access tokens. (#1356) * Specify a timeout when making the HTTP request to refresh access tokens. Without the timeout, some requests are silently never made. Fixes realm/realm-js-private#338. * Add a changelog entry. --- CHANGELOG.md | 1 + lib/user-methods.js | 5 ++++- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 8672dfd4..c1b5a08c 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -8,6 +8,7 @@ ### Bug fixes * Fixed port conflict between RN >= 0.48 inspector proxy and RPC server used for Chrome debugging (#1294). +* An issue where access tokens were not refreshed correctly has been addressed. ### Internal * Alignment of permission schemas. diff --git a/lib/user-methods.js b/lib/user-methods.js index 7296474b..0f317644 100644 --- a/lib/user-methods.js +++ b/lib/user-methods.js @@ -76,7 +76,10 @@ function refreshAccessToken(user, localRealmPath, realmUrl) { provider: 'realm', app_id: '' }), - headers: postHeaders + headers: postHeaders, + // FIXME: This timeout appears to be necessary in order for some requests to be sent at all. + // See https://github.com/realm/realm-js-private/issues/338 for details. + timeout: 1000.0 }; performFetch(url, options) .then((response) => response.json().then((json) => { return { response, json }; }))