Skip to content

Add keep alive env#194

Merged
anxolin merged 1 commit intomainfrom
keep-alive-env
Jan 22, 2026
Merged

Add keep alive env#194
anxolin merged 1 commit intomainfrom
keep-alive-env

Conversation

@anxolin
Copy link
Copy Markdown
Contributor

@anxolin anxolin commented Jan 22, 2026

This PR just allow to configure the keep alive interval by defining a new env var.

Summary by CodeRabbit

  • Chores
    • Updated environment configuration to support a configurable socket keep-alive interval, with a default value of 20000 milliseconds.

✏️ Tip: You can customize this high-level summary in your review settings.

@anxolin anxolin enabled auto-merge (squash) January 22, 2026 20:08
@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai bot commented Jan 22, 2026

📝 Walkthrough

Walkthrough

The changes introduce environment variable-based configuration for the keep-alive interval timeout in socket communications, replacing a hard-coded value with a configurable parameter that defaults to 20,000 milliseconds.

Changes

Cohort / File(s) Summary
Configuration Setup
.env.example
Added commented environment variable KEEP_ALIVE_INTERVAL_MS=20000 under Socket section to document the new configurable parameter.
API Route Logic
apps/api/src/app/routes/__chainId/accounts/__userAddress/balances/index.ts
Refactored keep-alive interval constant to read from environment variable with fallback default of 20,000 ms, replacing hard-coded value.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~8 minutes

Poem

🐰 A config born from hidden hard code,
Now dances freely in the .env abode,
Twenty thousand milliseconds stay alive,
Yet flexibility helps our system thrive! 💫

🚥 Pre-merge checks | ✅ 3
✅ Passed checks (3 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title 'Add keep alive env' accurately summarizes the main change: adding environment variable configuration for the keep-alive interval.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing touches
  • 📝 Generate docstrings

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.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link
Copy Markdown
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 2

🤖 Fix all issues with AI agents
In @.env.example:
- Line 115: Add a trailing newline at the end of the .env example so
dotenv-linter passes; specifically ensure the last line containing the commented
variable KEEP_ALIVE_INTERVAL_MS=20000 ends with a newline character (i.e., add a
blank final line) so the file terminates with a newline.

In `@apps/api/src/app/routes/__chainId/accounts/__userAddress/balances/index.ts`:
- Around line 17-19: The KEEP_ALIVE_INTERVAL_MS constant is parsed directly from
process.env and can be NaN or ≤0 causing setInterval to run immediately; update
the parsing in the module where KEEP_ALIVE_INTERVAL_MS is defined to use
parseInt with a radix, validate the result is a finite positive integer (e.g.
Number.isFinite and > 0) and if not, fall back to the default 20000, then export
that validated value (KEEP_ALIVE_INTERVAL_MS) so any setInterval call uses the
safe positive interval.

# SOCKET_API_KEY= No newline at end of file
# SOCKET_API_KEY=

# KEEP_ALIVE_INTERVAL_MS=20000 No newline at end of file
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🟡 Minor

Add trailing newline to satisfy dotenv-linter.
Minor formatting lint warning; add a final blank line.

💡 Suggested fix
 # KEEP_ALIVE_INTERVAL_MS=20000
+
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
# KEEP_ALIVE_INTERVAL_MS=20000
# KEEP_ALIVE_INTERVAL_MS=20000
🧰 Tools
🪛 dotenv-linter (4.0.0)

[warning] 115-115: [EndingBlankLine] No blank line at the end of the file

(EndingBlankLine)

🤖 Prompt for AI Agents
In @.env.example at line 115, Add a trailing newline at the end of the .env
example so dotenv-linter passes; specifically ensure the last line containing
the commented variable KEEP_ALIVE_INTERVAL_MS=20000 ends with a newline
character (i.e., add a blank final line) so the file terminates with a newline.

Comment on lines +17 to +19
const KEEP_ALIVE_INTERVAL_MS = parseInt(
process.env.KEEP_ALIVE_INTERVAL_MS || '20000' // 20 seconds
);
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🟠 Major

Guard against invalid/zero keep-alive intervals.
If the env var is non-numeric or ≤0, setInterval can run immediately, causing a tight loop. Validate and fallback to the default.

🛠️ Suggested fix
-const KEEP_ALIVE_INTERVAL_MS = parseInt(
-  process.env.KEEP_ALIVE_INTERVAL_MS || '20000' // 20 seconds
-);
+const KEEP_ALIVE_INTERVAL_MS = (() => {
+  const raw = Number(process.env.KEEP_ALIVE_INTERVAL_MS);
+  return Number.isFinite(raw) && raw > 0 ? raw : 20000; // 20 seconds
+})();
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
const KEEP_ALIVE_INTERVAL_MS = parseInt(
process.env.KEEP_ALIVE_INTERVAL_MS || '20000' // 20 seconds
);
const KEEP_ALIVE_INTERVAL_MS = (() => {
const raw = Number(process.env.KEEP_ALIVE_INTERVAL_MS);
return Number.isFinite(raw) && raw > 0 ? raw : 20000; // 20 seconds
})();
🤖 Prompt for AI Agents
In `@apps/api/src/app/routes/__chainId/accounts/__userAddress/balances/index.ts`
around lines 17 - 19, The KEEP_ALIVE_INTERVAL_MS constant is parsed directly
from process.env and can be NaN or ≤0 causing setInterval to run immediately;
update the parsing in the module where KEEP_ALIVE_INTERVAL_MS is defined to use
parseInt with a radix, validate the result is a finite positive integer (e.g.
Number.isFinite and > 0) and if not, fall back to the default 20000, then export
that validated value (KEEP_ALIVE_INTERVAL_MS) so any setInterval call uses the
safe positive interval.

@anxolin anxolin disabled auto-merge January 22, 2026 20:45
@anxolin anxolin merged commit 91e3f33 into main Jan 22, 2026
9 checks passed
@anxolin anxolin deleted the keep-alive-env branch January 22, 2026 20:45
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant