fix(relay): Telegram + OOM + memory cleanup#531
Conversation
… cleanup - Add `telegram` and `ws` to root dependencies so Railway's `npm install` installs them - Log V8 heap limit at startup to confirm NODE_OPTIONS is active - Make MAX_VESSELS/MAX_VESSEL_HISTORY env-configurable (default 20k, down from 50k) - Add permanent latch to skip Telegram import retries when package is missing - Raise memory cleanup threshold from 450MB to 2GB (env-configurable) - Clear all caches (RSS, Polymarket, WorldBank) during emergency cleanup
|
The latest updates on your projects. Learn more about Vercel for GitHub. 4 Skipped Deployments
|
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 2494fbfe92
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| const n = Number(envVal); | ||
| return Number.isFinite(n) ? Math.max(min, Math.floor(n)) : fallback; |
There was a problem hiding this comment.
Handle empty AIS cap env vars as unset
The new safeInt parser treats an empty string as a valid number (Number('') === 0), so if AIS_MAX_VESSELS or AIS_MAX_VESSEL_HISTORY is present but blank (a common misconfiguration in managed env UIs), the cap is forced to 1000 instead of using the intended default 20000. That silently shrinks retention by 20x and can cause aggressive eviction/data loss in normal operation; blank values should fall back to defaults rather than being clamped to min.
Useful? React with 👍 / 👎.
Number('') === 0 passes isFinite, silently clamping caps to 1000
instead of using the 20000 default. Guard empty/null before parsing.
Summary
telegramandwsadded to rootdependencies(Railway runsnpm installat repo root, notscripts/)NODE_OPTIONS=--max-old-space-size=8192is active;MAX_VESSELS/MAX_VESSEL_HISTORYlowered from 50k→20k (env-configurable)RELAY_MEMORY_CLEANUP_GB); emergency cleanup now clears all caches (RSS, Polymarket, WorldBank)Railway env vars to set
After 30+ min stability, flip
POLYMARKET_ENABLED=true.Test plan
node --check scripts/ais-relay.cjs— syntax OKnode -e "require('telegram')"— resolves from rootnode --test scripts/ais-relay-rss.test.cjs— 5/5 passtsc --noEmit— clean[Relay] Heap limit: 8192MBin logsCannot find package 'telegram'errors