From 7ac9571ce43df8320b45a3bd249dd09e551940fd Mon Sep 17 00:00:00 2001 From: Matchu Date: Fri, 22 Jan 2021 14:47:18 -0800 Subject: [PATCH] Add error wrapper for potential `title` bug source --- src/app/util.js | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/src/app/util.js b/src/app/util.js index adbc144..edab96e 100644 --- a/src/app/util.js +++ b/src/app/util.js @@ -182,7 +182,21 @@ export function useDebounce( export function usePageTitle(title, { skip = false } = {}) { React.useEffect(() => { if (skip) return; - document.title = title ? `${title} | Dress to Impress` : "Dress to Impress"; + try { + document.title = title + ? `${title} | Dress to Impress` + : "Dress to Impress"; + } catch (e) { + // I've been seeing Sentry errors that we can't read `title` of + // undefined, with no traceback. This is the only `.title` I see in our + // codebase, aside from unpacking props that I'm pretty sure aren't + // null... so I'm adding this to help confirm! + logAndCapture( + new Error( + `Could not set page title: ${e.message}. Document is: ${document}.` + ) + ); + } }, [title, skip]); }