From f3e19158d04b124d8770f4c4236a2b61c5525a56 Mon Sep 17 00:00:00 2001 From: Matchu Date: Wed, 3 Feb 2021 15:51:49 -0800 Subject: [PATCH] Fix crash when using old tab to load item page MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Oops, the new `canonicalAppearance` arguments couldn't handle being omitted rather than being null, due to a low-level SQL call site that cares about the difference. This meant that loading an item page in an old tab, with an old copy of our JS, could cause a crash. Now, the backend will be okay with queries from old pages, and respond the same as before! This isn't a huge deal, because once everyone is on the new JS we won't send queries without this parameter anyway… but I like my optional arguments to actually BE optional, without surprises lurking >.> --- src/server/loaders.js | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/server/loaders.js b/src/server/loaders.js index d809aa9..b6a6e46 100644 --- a/src/server/loaders.js +++ b/src/server/loaders.js @@ -1005,7 +1005,12 @@ const buildCanonicalPetStateForBodyLoader = (db, loaders) => LIMIT 1`, nestTables: true, }, - [bodyId, preferredColorId, fallbackColorId, gender === "fem"] + [ + bodyId, + preferredColorId || "", + fallbackColorId, + gender === "fem", + ] ); const petState = normalizeRow(rows[0].pet_states); const petType = normalizeRow(rows[0].pet_types);