Summary of What Needs to be Done
src/utils/timeSync.js reads from localStorage at module initialization time (top-level code in the module scope) without checking if the code is running in a server-side rendering environment. In Node.js / SSR contexts, localStorage is undefined, causing a TypeError that crashes the render.
Changes
Wrap the module-level localStorage access in a typeof localStorage !== "undefined" guard, consistent with how other files in the codebase handle SSR (e.g., safeStorage.js, storageUtils.js).
Impact
- SSR crash: Any page that imports
timeSync.js during server-side rendering will throw TypeError: localStorage is not defined, breaking the build.
- Affects functions
setServerClockOffsetMs and the module initialization block that reads the cached offset.
Please assign this task to me.
Summary of What Needs to be Done
src/utils/timeSync.jsreads fromlocalStorageat module initialization time (top-level code in the module scope) without checking if the code is running in a server-side rendering environment. In Node.js / SSR contexts,localStorageis undefined, causing aTypeErrorthat crashes the render.Changes
Wrap the module-level
localStorageaccess in atypeof localStorage !== "undefined"guard, consistent with how other files in the codebase handle SSR (e.g.,safeStorage.js,storageUtils.js).Impact
timeSync.jsduring server-side rendering will throwTypeError: localStorage is not defined, breaking the build.setServerClockOffsetMsand the module initialization block that reads the cached offset.Please assign this task to me.