-
Notifications
You must be signed in to change notification settings - Fork 3
fix(backend): resolve frontendWorker memory leaks #586
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
## Problem
The frontendWorker processes were consuming excessive memory (~6.5GB each),
causing high RAM usage with multiple worker instances.
## Root Causes
1. **Memory leak in intents.ts getPrice()**
- Every call to getPrice() created a new ApiPromise with WsProvider
- These connections were never closed, accumulating WebSocket connections,
WASM crypto modules, and type registries in memory
2. **Duplicate @polkadot/* package versions**
- Multiple versions of @polkadot/util (13.5.6, 13.5.9), @polkadot/wasm-crypto
(7.5.1, 7.5.4), and other packages were being loaded
- Each duplicate loads its own WASM modules and internal state
## Fixes
1. **Singleton API pattern for price queries**
- Created getPriceApi() that maintains a single ApiPromise instance
- Handles disconnection/error events to reset and reconnect on next query
- Prevents accumulation of orphaned WebSocket connections
2. **Package resolutions for @polkadot/* deduplication**
- Added resolutions in root package.json to force single versions:
- @polkadot/util, util-crypto, keyring: 13.5.6
- @polkadot/wasm-*: 7.5.1
- Eliminates duplicate WASM module loading
## Impact
- Significantly reduced memory footprint per worker process
- Eliminated WebSocket connection accumulation
- Reduced initial load time due to single WASM initialization
❌ Deploy Preview for auto-drive-storage failed. Why did it fail? →
|
❌ Deploy Preview for auto-drive-demo failed. Why did it fail? →
|
|
Warning Review the following alerts detected in dependencies. According to your organization's Security Policy, it is recommended to resolve "Warn" alerts. Learn more about Socket for GitHub.
|
|
Closed as replaced by #587 |
Problem
The frontendWorker processes were consuming excessive memory (~6.5GB each), causing high RAM usage with multiple worker instances.
Root Causes
Memory leak in intents.ts getPrice()
Duplicate @polkadot/ package versions*
Fixes
Singleton API pattern for price queries
Package resolutions for @polkadot/ deduplication*
Impact