[PR #5468] [MERGED] fix(frontend): guard IntlUtil.formatDate against out-of-range timestamps #5890

Closed
opened 2026-11-02 04:04:48 +07:00 by bsakaguchi · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/MHSanaei/3x-ui/pull/5468
Author: @NikanZeyaei
Created: 6/21/2026
Status: ✅ Merged
Merged: 6/21/2026
Merged by: @MHSanaei

Base: main ← Head: fix/intl-formatdate-finite-check


📝 Commits (1)

  • b15d4aa fix(frontend): guard IntlUtil.formatDate against out-of-range timestamps

📊 Changes

1 file changed (+4 additions, -1 deletions)

View changed files

📝 frontend/src/utils/index.ts (+4 -1)

📄 Description

Summary

Closes https://github.com/MHSanaei/3x-ui/issues/5464
Guard IntlUtil.formatDate against out-of-range timestamps so a single bad expiryTime can't crash the clients page.

Why

Backend ExpiryTime is a Go int64; JS Date only accepts ±8,640,000,000,000,000 ms. A value beyond that yields Invalid Date, and Intl.DateTimeFormat.format(Invalid Date) throws — taking down ClientsPage for every user.

Type of change

  • Bug fix
  • New feature
  • Refactoring (no behavior change)
  • Documentation
  • Tests only
  • Build / CI / tooling
  • Other

Areas affected

  • Frontend (UI / panel pages)
  • Backend (API endpoints, login, settings)
  • Xray config generation
  • Subscription (share links / Clash / JSON)
  • Statistics / traffic counters
  • Database / migrations
  • Install / upgrade script
  • Docker image
  • Multi-node (sub-nodes)
  • Telegram bot

How was this tested?

Reproduced in browser devtools:

new Intl.DateTimeFormat('en').format(new Date(8640000000000001))
// throws: `RangeError: date value is not finite in DateTimeFormat format()`

After the fix, IntlUtil.formatDate(8640000000000001) returns '' instead of throwing.

Screenshots / recordings

N/A

Breaking changes

None

Checklist

  • I tested the change locally and confirmed the described behavior.
  • I added or updated tests for the new behavior (when applicable).
  • go build ./... and the test suite pass locally.
  • For frontend changes: npm run lint, npm run typecheck, and npm run build pass.
  • I updated the Wiki / README / API docs if user-facing behavior changed.
  • My commits follow the project's existing message style.
  • I have no unrelated changes mixed into this PR.

🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/MHSanaei/3x-ui/pull/5468 **Author:** [@NikanZeyaei](https://github.com/NikanZeyaei) **Created:** 6/21/2026 **Status:** ✅ Merged **Merged:** 6/21/2026 **Merged by:** [@MHSanaei](https://github.com/MHSanaei) **Base:** `main` ← **Head:** `fix/intl-formatdate-finite-check` --- ### 📝 Commits (1) - [`b15d4aa`](https://github.com/MHSanaei/3x-ui/commit/b15d4aab09c9328e403c3b410134c820b912c4c7) fix(frontend): guard IntlUtil.formatDate against out-of-range timestamps ### 📊 Changes **1 file changed** (+4 additions, -1 deletions) <details> <summary>View changed files</summary> 📝 `frontend/src/utils/index.ts` (+4 -1) </details> ### 📄 Description ## Summary Closes https://github.com/MHSanaei/3x-ui/issues/5464 Guard `IntlUtil.formatDate` against out-of-range timestamps so a single bad `expiryTime` can't crash the clients page. ## Why Backend `ExpiryTime` is a Go `int64`; JS `Date` only accepts ±8,640,000,000,000,000 ms. A value beyond that yields `Invalid Date`, and `Intl.DateTimeFormat.format(Invalid Date)` throws — taking down `ClientsPage` for every user. ## Type of change - [x] Bug fix - [ ] New feature - [ ] Refactoring (no behavior change) - [ ] Documentation - [ ] Tests only - [ ] Build / CI / tooling - [ ] Other ## Areas affected - [x] Frontend (UI / panel pages) - [ ] Backend (API endpoints, login, settings) - [ ] Xray config generation - [ ] Subscription (share links / Clash / JSON) - [ ] Statistics / traffic counters - [ ] Database / migrations - [ ] Install / upgrade script - [ ] Docker image - [ ] Multi-node (sub-nodes) - [ ] Telegram bot ## How was this tested? Reproduced in browser devtools: ```js new Intl.DateTimeFormat('en').format(new Date(8640000000000001)) // throws: `RangeError: date value is not finite in DateTimeFormat format()` ``` After the fix, `IntlUtil.formatDate(8640000000000001)` returns `''` instead of throwing. ## Screenshots / recordings N/A ## Breaking changes None ## Checklist - [x] I tested the change locally and confirmed the described behavior. - [ ] I added or updated tests for the new behavior (when applicable). - [x] `go build ./...` and the test suite pass locally. - [x] For frontend changes: `npm run lint`, `npm run typecheck`, and `npm run build` pass. - [ ] I updated the Wiki / README / API docs if user-facing behavior changed. - [x] My commits follow the project's existing message style. - [x] I have no unrelated changes mixed into this PR. --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
bsakaguchi 2026-11-02 04:04:48 +07:00
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
MHSanaei/3x-ui#5890
No description provided.