Fix blank Query Tool screen caused by a malformed runtime locale (#7596)#10066
Fix blank Query Tool screen caused by a malformed runtime locale (#7596)#10066dpage wants to merge 1 commit into
Conversation
The Query History panel formats entry dates/times with Date.prototype.toLocaleDateString()/toLocaleTimeString(). On runtimes whose default locale (derived from the OS/environment) is malformed, these throw "RangeError: Incorrect locale information provided". Because getDateFormatted()/getTimeFormatted() are called during render (via getGroups/getGroupHeader/getDatePrefix), the uncaught exception unmounts the whole SQL editor React tree, leaving the user with a blank white screen and losing any unsaved query work. Guard both helpers and fall back to a moment-based format (moment uses its own locale data and does not depend on the broken Intl default) so the editor keeps working instead of crashing. Closes pgadmin-org#7596
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Path: .coderabbit.yaml Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (3)
WalkthroughThis PR fixes a blank-screen crash in the Query Tool by adding defensive error handling to Query History date/time formatting. When the runtime OS/Intl locale is malformed, ChangesQuery Tool locale resilience
🎯 2 (Simple) | ⏱️ ~10 minutes 🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Pull request overview
Guards Query History date/time formatting in the SQL editor against RangeError: Incorrect locale information provided (malformed runtime locale) to prevent a render-time crash that blanks the Query Tool UI.
Changes:
- Wrap
toLocaleDateString()/toLocaleTimeString()in try/catch and fall back tomomentformatting. - Add Jest regression coverage for both normal formatting and the RangeError fallback scenario.
- Document the fix in the 9.16 release notes.
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 3 comments.
| File | Description |
|---|---|
| web/pgadmin/tools/sqleditor/static/js/components/sections/QueryHistory.jsx | Adds guarded locale formatting with moment fallback to avoid render-time crashes. |
| web/regression/javascript/sqleditor/QueryHistory.spec.js | Adds regression tests ensuring formatting does not throw when toLocale*String raises RangeError. |
| docs/en_US/release_notes_9_16.rst | Adds a bug-fix entry for issue #7596. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| export function getDateFormatted(date) { | ||
| try { | ||
| return date.toLocaleDateString(); | ||
| } catch { | ||
| return moment(date).format('L'); | ||
| } | ||
| } |
| export function getTimeFormatted(time) { | ||
| try { | ||
| return time.toLocaleTimeString(); | ||
| } catch { | ||
| return moment(time).format('LTS'); | ||
| } | ||
| } |
| // | ||
| // pgAdmin 4 - PostgreSQL Tools | ||
| // | ||
| // Copyright (C) 2013 - 2025, The pgAdmin Development Team |
Summary
The Query History panel formats entry dates/times with
Date.prototype.toLocaleDateString()/toLocaleTimeString()(called with noarguments, i.e. using the runtime's default locale). On runtimes whose default
locale — derived from the OS/Electron environment — is malformed, V8 throws:
These helpers run during render (
getGroups→getGroupHeader→getDatePrefix→isDaysBefore), so the uncaught exception unmounts the entireSQL editor React tree. The user is left with a blank white screen and loses
any unsaved query work — the symptom reported in #7596 (and matching the 9.2
stack trace posted there).
This change guards both helpers and falls back to a
moment-based format(
momentis already imported here and uses its own locale data, independent ofthe broken Intl default), so the editor keeps working instead of crashing.
Scope note
#7596 is a long-running catch-all whose comments conflate several distinct
failures (an Object Explorer scroll crash reported fixed in 9.0, transient
network 500s, and this locale crash). This PR targets the locale
RangeErrorspecifically — the most concrete, currently-reproducible cause.
Test plan
QueryHistory.spec.js: verifies normal locale formatting and thatthe helpers no longer throw / return a usable string when
toLocale*Stringraises theRangeError(regression test for Screen goes white and unusable, losing all query progress as no ability to save #7596).yarn jest QueryHistory— 4 passing.eslint -c .eslintrc.json the changed files — clean.Closes #7596
Summary by CodeRabbit
Release Notes
Bug Fixes
Tests