Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .changeset/uplot-posix-locale.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@hyperdx/app': patch
---

fix: The app no longer crashes on load in browsers that report a POSIX-style language such as `en-US@posix`
40 changes: 40 additions & 0 deletions .yarn/patches/uplot-npm-1.6.32-350d2da00d.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
diff --git a/dist/uPlot.cjs.js b/dist/uPlot.cjs.js
index 98b7582dff68d4f4d9e0068cc77bec9d33ea4904..d137fbcb9f24358d7e59350907181106fc5b231d 100644
--- a/dist/uPlot.cjs.js
+++ b/dist/uPlot.cjs.js
@@ -441,7 +441,14 @@ function _rangeNum(_min, _max, cfg) {
}

// alternative: https://stackoverflow.com/a/2254896
-const numFormatter = new Intl.NumberFormat(domEnv ? nav.language : 'en-US');
+// Patched: Intl rejects POSIX-style tags such as 'en-US@posix', which some
+// browsers report as navigator.language. Fall back instead of throwing at import.
+let numFormatter;
+try {
+ numFormatter = new Intl.NumberFormat(domEnv ? nav.language : 'en-US');
+} catch (e) {
+ numFormatter = new Intl.NumberFormat('en-US');
+}
const fmtNum = val => numFormatter.format(val);

const M = Math;
diff --git a/dist/uPlot.esm.js b/dist/uPlot.esm.js
index 87473c9cfb3366f57883cb803114a87c64d4b6b8..740bd3626a1f8bd6bbe352878e55e898e759784c 100644
--- a/dist/uPlot.esm.js
+++ b/dist/uPlot.esm.js
@@ -439,7 +439,14 @@ function _rangeNum(_min, _max, cfg) {
}

// alternative: https://stackoverflow.com/a/2254896
-const numFormatter = new Intl.NumberFormat(domEnv ? nav.language : 'en-US');
+// Patched: Intl rejects POSIX-style tags such as 'en-US@posix', which some
+// browsers report as navigator.language. Fall back instead of throwing at import.
+let numFormatter;
+try {
+ numFormatter = new Intl.NumberFormat(domEnv ? nav.language : 'en-US');
+} catch (e) {
+ numFormatter = new Intl.NumberFormat('en-US');
+}
const fmtNum = val => numFormatter.format(val);

const M = Math;
2 changes: 1 addition & 1 deletion packages/app/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@
"store2": "^2.14.3",
"strip-ansi": "^6.0.1",
"timestamp-nano": "^1.0.1",
"uplot": "^1.6.31",
"uplot": "patch:uplot@npm%3A1.6.32#~/.yarn/patches/uplot-npm-1.6.32-350d2da00d.patch",
"uplot-react": "^1.2.2",
"zod": "3.25"
},
Expand Down
3 changes: 3 additions & 0 deletions packages/app/playwright.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,9 @@ export default defineConfig({
screenshot: 'only-on-failure',
/* Record video on failure */
video: 'retain-on-failure',
// Otherwise Chromium takes navigator.language from the host locale, so
// number and date formatting would vary between machines.
locale: 'en-US',
},

/* Global test timeout - CI needs more time than local */
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
// uPlot builds an Intl.NumberFormat from navigator.language at import time.
// Chromium on LANG=C.UTF-8 hosts reports 'en-US@posix', which Intl rejects;
// our yarn patch makes uPlot fall back to 'en-US' instead of throwing.
describe('uplot locale patch', () => {
let languageSpy: jest.SpyInstance;

afterEach(() => {
languageSpy.mockRestore();
});

it('imports and formats numbers when navigator.language is not a valid BCP 47 tag', async () => {
languageSpy = jest
.spyOn(window.navigator, 'language', 'get')
.mockReturnValue('en-US@posix');

expect(() => new Intl.NumberFormat('en-US@posix')).toThrow(RangeError);

await jest.isolateModulesAsync(async () => {
const { default: uPlot } = await import('uplot');
expect(uPlot.fmtNum(1234.5)).toBe('1,234.5');
});
});
});
6 changes: 5 additions & 1 deletion packages/app/tests/e2e/global-setup-fullstack.ts
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,11 @@ async function globalSetup(_config: FullConfig) {
console.log('Creating test user and logging in');

const browser = await chromium.launch();
const context = await browser.newContext({ baseURL: APP_URL });
// Global setup doesn't inherit `use` from playwright.config.ts.
const context = await browser.newContext({
baseURL: APP_URL,
locale: 'en-US',
});
const page = await context.newPage();

try {
Expand Down
11 changes: 9 additions & 2 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -4977,7 +4977,7 @@ __metadata:
timestamp-nano: "npm:^1.0.1"
ts-jest: "npm:^29.4.11"
typescript: "npm:^6.0.3"
uplot: "npm:^1.6.31"
uplot: "patch:uplot@npm%3A1.6.32#~/.yarn/patches/uplot-npm-1.6.32-350d2da00d.patch"
uplot-react: "npm:^1.2.2"
zod: "npm:3.25"
languageName: unknown
Expand Down Expand Up @@ -30604,13 +30604,20 @@ __metadata:
languageName: node
linkType: hard

"uplot@npm:^1.6.31":
"uplot@npm:1.6.32":
version: 1.6.32
resolution: "uplot@npm:1.6.32"
checksum: 10c0/4d9cdd5f53371656cfc178ea4ae0d8c9bdbe4c98c99df847926d7e5f5a5bcb8043561219da2979fee7616aabe3619d80fee093befdfe39aae65e6621284c39b1
languageName: node
linkType: hard

"uplot@patch:uplot@npm%3A1.6.32#~/.yarn/patches/uplot-npm-1.6.32-350d2da00d.patch":
version: 1.6.32
resolution: "uplot@patch:uplot@npm%3A1.6.32#~/.yarn/patches/uplot-npm-1.6.32-350d2da00d.patch::version=1.6.32&hash=d25b41"
checksum: 10c0/8eac8ee3e294a2834f6295eea230bd6dba6c7031a0d67f79f02eacec15ceaada5e82accd9ef1b6462326ec35e9475779f072b9be7625550a3e2f1d8fc70d2470
languageName: node
linkType: hard

"uri-js@npm:^4.2.2":
version: 4.4.1
resolution: "uri-js@npm:4.4.1"
Expand Down
Loading