From 0d76ea0aab14bfe3fb8ec4e3197a59c2310102b0 Mon Sep 17 00:00:00 2001 From: Matt Cowan Date: Fri, 22 Jun 2018 16:09:24 -0400 Subject: [PATCH] Ensure flags isn't set to null if bootstrapping When upgrading from 1.7.0 to 2.1.2 we ran into an unexpected breaking change where although we bootstrap with localStorage, the flags would now be set to `null` leading to any calls to `variation` to throw until the client is fully ready. The behavior in the older version with the empty object allowed calls to `variation` to succeed before ready, but would simply use the default fallback value. This change restores that old behavior. --- src/index.js | 1 + 1 file changed, 1 insertion(+) diff --git a/src/index.js b/src/index.js index 729436d2..605469ee 100644 --- a/src/index.js +++ b/src/index.js @@ -405,6 +405,7 @@ function initialize(env, user, options = {}) { flags = store.loadFlags(); if (flags === null) { + flags = {} requestor.fetchFlagSettings(ident.getUser(), hash, (err, settings) => { if (err) { emitter.maybeReportError(new errors.LDFlagFetchError(messages.errorFetchingFlags(err)));