-
Notifications
You must be signed in to change notification settings - Fork 10.2k
fix: refactor i18n loadTranslations
and set timeout to 3s
#22633
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
WalkthroughA new asynchronous utility function, Estimated code review effort3 (90–240 minutes) Warning There were issues while running some tools. Please review the errors and either fix the tool's configuration or disable the tool if it's a critical failure. 🔧 ESLint
packages/features/ee/billing/credit-service.test.tsOops! Something went wrong! :( ESLint: 8.57.1 ESLint couldn't find the plugin "eslint-plugin-playwright". (The package "eslint-plugin-playwright" was not found when loaded as a Node module from the directory "".) It's likely that the plugin isn't installed correctly. Try reinstalling by running the following:
The plugin "eslint-plugin-playwright" was referenced from the config file in ".eslintrc.js". If you still can't figure out the problem, please stop by https://eslint.org/chat/help to chat with the team. packages/features/ee/organizations/lib/server/createOrganizationFromOnboarding.test.tsOops! Something went wrong! :( ESLint: 8.57.1 ESLint couldn't find the plugin "eslint-plugin-playwright". (The package "eslint-plugin-playwright" was not found when loaded as a Node module from the directory "".) It's likely that the plugin isn't installed correctly. Try reinstalling by running the following:
The plugin "eslint-plugin-playwright" was referenced from the config file in ".eslintrc.js". If you still can't figure out the problem, please stop by https://eslint.org/chat/help to chat with the team. packages/features/ee/workflows/lib/reminders/reminderScheduler.test.tsOops! Something went wrong! :( ESLint: 8.57.1 ESLint couldn't find the plugin "eslint-plugin-playwright". (The package "eslint-plugin-playwright" was not found when loaded as a Node module from the directory "".) It's likely that the plugin isn't installed correctly. Try reinstalling by running the following:
The plugin "eslint-plugin-playwright" was referenced from the config file in ".eslintrc.js". If you still can't figure out the problem, please stop by https://eslint.org/chat/help to chat with the team.
📜 Recent review detailsConfiguration used: CodeRabbit UI 📒 Files selected for processing (7)
✅ Files skipped from review due to trivial changes (3)
🚧 Files skipped from review as they are similar to previous changes (1)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (1)
🔇 Additional comments (3)
✨ Finishing Touches
🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
SupportNeed help? Create a ticket on our support page for assistance with any issues or questions. Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments. CodeRabbit Commands (Invoked using PR comments)
Other keywords and placeholders
CodeRabbit Configuration File (
|
loadTranslations
and set timeout to 3s
The latest updates on your projects. Learn more about Vercel for Git ↗︎ |
✅ No security or compliance issues detected. Reviewed everything up to 1a89321. Security Overview
Detected Code Changes
Reply to this PR with |
✅ No security or compliance issues detected. Reviewed everything up to 85edbca. Security Overview
Detected Code Changes
Reply to this PR with |
Graphite Automations"Add consumer team as reviewer" took an action on this PR • (07/18/25)1 reviewer was added to this PR based on Keith Williams's automation. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Code LGTM. Is there any reason why timeouts are happening tho?
const controller = new AbortController(); | ||
const timeout = setTimeout(() => controller.abort(), timeoutMs); | ||
try { | ||
const response = await fetch(url, { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is there not just a value you can send in fetch instead of needing to set a timeout?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nope :( I searched something like that but there wasn't. Lmk if you know something!
E2E results are ready! |
We didn't validate locale or namespace before making a |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 1
♻️ Duplicate comments (1)
packages/lib/server/i18n.ts (1)
11-11
: Address the hardcoded namespace list as previously discussed.Based on past review comments, this hardcoded list creates maintenance overhead as it's duplicated elsewhere in the codebase.
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (5)
packages/features/ee/billing/credit-service.test.ts
(1 hunks)packages/features/ee/organizations/lib/server/createOrganizationFromOnboarding.test.ts
(1 hunks)packages/features/ee/workflows/lib/reminders/reminderScheduler.test.ts
(1 hunks)packages/features/ee/workflows/lib/test/compareReminderBodyToTemplate.test.ts
(2 hunks)packages/lib/server/i18n.ts
(1 hunks)
✅ Files skipped from review due to trivial changes (3)
- packages/features/ee/organizations/lib/server/createOrganizationFromOnboarding.test.ts
- packages/features/ee/workflows/lib/reminders/reminderScheduler.test.ts
- packages/features/ee/billing/credit-service.test.ts
🧰 Additional context used
🧠 Learnings (1)
packages/lib/server/i18n.ts (1)
Learnt from: bandhan-majumder
PR: calcom/cal.com#22359
File: packages/lib/server/locales/en/common.json:1336-1339
Timestamp: 2025-07-14T16:31:45.201Z
Learning: When making localization changes for new features, it's often safer to add new strings rather than modify existing ones to avoid breaking existing functionality that depends on the original strings. This approach allows for feature-specific customization while maintaining backward compatibility.
🧬 Code Graph Analysis (1)
packages/lib/server/i18n.ts (3)
packages/config/next-i18next.config.d.ts (1)
i18n
(2-5)packages/lib/constants.ts (1)
WEBAPP_URL
(12-18)packages/lib/fetchWithTimeout.ts (1)
fetchWithTimeout
(1-13)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (3)
- GitHub Check: Install dependencies / Yarn install & cache
- GitHub Check: Codacy Static Code Analysis
- GitHub Check: Security Check
🔇 Additional comments (6)
packages/features/ee/workflows/lib/test/compareReminderBodyToTemplate.test.ts (2)
2-2
: LGTM: Added vitest import for mocking.The addition of
vi
import enables proper mocking functionality for the test suite.
13-17
: LGTM: Appropriate mocking of i18n module.The mock implementation correctly stubs the
getTranslation
function to return the input key, which is appropriate for testing purposes and isolates tests from the actual i18n implementation changes.packages/lib/server/i18n.ts (4)
3-3
: LGTM: Added i18n config import for locale validation.The import enables proper validation of locales against the supported list from the configuration.
6-8
: LGTM: Added necessary imports for timeout and logging.The new imports support the enhanced error handling and timeout functionality.
19-22
: LGTM: Robust validation and normalization logic.The implementation correctly:
- Normalizes "zh" to "zh-CN" for proper locale handling
- Validates locales against the supported list from configuration
- Validates namespaces against the supported list
- Falls back to safe defaults ("en" locale, "common" namespace)
This addresses the core issue mentioned in PR objectives where invalid parameters could cause fetch requests to hang.
38-46
: LGTM: Improved error handling with proper logging.The error handling correctly:
- Logs fetch failures for debugging
- Returns an empty object instead of throwing
- Maintains the caching mechanism for successful responses
This is a significant improvement over the previous fallback approach, as it prevents cascading failures and provides clearer error visibility.
@keithwillcode Keith, can you review it once more? |
What does this PR do?
common
namespaceMandatory Tasks (DO NOT REMOVE)
How should this be tested?