Skip to content

Conversation

@EmilFattakhov
Copy link
Member

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

## 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
@netlify
Copy link

netlify bot commented Feb 6, 2026

Deploy Preview for auto-drive-storage failed. Why did it fail? →

Name Link
🔨 Latest commit 6052c17
🔍 Latest deploy log https://app.netlify.com/projects/auto-drive-storage/deploys/698563348e1b2000088c6c0b

@netlify
Copy link

netlify bot commented Feb 6, 2026

Deploy Preview for auto-drive-demo failed. Why did it fail? →

Name Link
🔨 Latest commit 6052c17
🔍 Latest deploy log https://app.netlify.com/projects/auto-drive-demo/deploys/698563347099070008a18860

@socket-security
Copy link

@socket-security
Copy link

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.

Action Severity Alert  (click "▶" to expand/collapse)
Warn Critical
Critical CVE: Next.js is vulnerable to RCE in React flight protocol

CVE: GHSA-9qr9-h5gf-34mp Next.js is vulnerable to RCE in React flight protocol (CRITICAL)

Affected versions: >= 14.3.0-canary.77 < 15.0.5; >= 15.1.0-canary.0 < 15.1.9; >= 15.2.0-canary.0 < 15.2.6; >= 15.3.0-canary.0 < 15.3.6; >= 15.4.0-canary.0 < 15.4.8; >= 15.5.0-canary.0 < 15.5.7; >= 16.0.0-canary.0 < 16.0.7

Patched version: 15.5.7

From: ?npm/@autonomys/auto-design-system@1.6.5npm/next@15.5.4

ℹ Read more on: This package | This alert | What is a critical CVE?

Next steps: Take a moment to review the security alert above. Review the linked package source code to understand the potential risk. Ensure the package is not malicious before proceeding. If you're unsure how to proceed, reach out to your security team or ask the Socket team for help at support@socket.dev.

Suggestion: Remove or replace dependencies that include known critical CVEs. Consumers can use dependency overrides or npm audit fix --force to remove vulnerable dependencies.

Mark the package as acceptable risk. To ignore this alert only in this pull request, reply with the comment @SocketSecurity ignore npm/next@15.5.4. You can also ignore all packages with @SocketSecurity ignore-all. To ignore an alert for all future pull requests, use Socket's Dashboard to change the triage state of this alert.

Warn High
Obfuscated code: npm @graphql-tools/github-loader is 98.0% likely obfuscated

Confidence: 0.98

Location: Package overview

From: ?npm/@graphql-codegen/cli@5.0.7npm/@graphql-tools/github-loader@8.0.22

ℹ Read more on: This package | This alert | What is obfuscated code?

Next steps: Take a moment to review the security alert above. Review the linked package source code to understand the potential risk. Ensure the package is not malicious before proceeding. If you're unsure how to proceed, reach out to your security team or ask the Socket team for help at support@socket.dev.

Suggestion: Packages should not obfuscate their code. Consider not using packages with obfuscated code.

Mark the package as acceptable risk. To ignore this alert only in this pull request, reply with the comment @SocketSecurity ignore npm/@graphql-tools/github-loader@8.0.22. You can also ignore all packages with @SocketSecurity ignore-all. To ignore an alert for all future pull requests, use Socket's Dashboard to change the triage state of this alert.

Warn High
Obfuscated code: npm @polkadot/util-crypto is 91.0% likely obfuscated

Confidence: 0.91

Location: Package overview

From: apps/backend/package.jsonnpm/@polkadot/util-crypto@13.5.6

ℹ Read more on: This package | This alert | What is obfuscated code?

Next steps: Take a moment to review the security alert above. Review the linked package source code to understand the potential risk. Ensure the package is not malicious before proceeding. If you're unsure how to proceed, reach out to your security team or ask the Socket team for help at support@socket.dev.

Suggestion: Packages should not obfuscate their code. Consider not using packages with obfuscated code.

Mark the package as acceptable risk. To ignore this alert only in this pull request, reply with the comment @SocketSecurity ignore npm/@polkadot/util-crypto@13.5.6. You can also ignore all packages with @SocketSecurity ignore-all. To ignore an alert for all future pull requests, use Socket's Dashboard to change the triage state of this alert.

Warn High
Obfuscated code: npm @webbuf/webbuf is 90.0% likely obfuscated

Confidence: 0.90

Location: Package overview

From: ?npm/@autonomys/auto-dag-data@1.6.5npm/@webbuf/webbuf@3.0.28

ℹ Read more on: This package | This alert | What is obfuscated code?

Next steps: Take a moment to review the security alert above. Review the linked package source code to understand the potential risk. Ensure the package is not malicious before proceeding. If you're unsure how to proceed, reach out to your security team or ask the Socket team for help at support@socket.dev.

Suggestion: Packages should not obfuscate their code. Consider not using packages with obfuscated code.

Mark the package as acceptable risk. To ignore this alert only in this pull request, reply with the comment @SocketSecurity ignore npm/@webbuf/webbuf@3.0.28. You can also ignore all packages with @SocketSecurity ignore-all. To ignore an alert for all future pull requests, use Socket's Dashboard to change the triage state of this alert.

Warn High
Obfuscated code: npm apg-js is 98.0% likely obfuscated

Confidence: 0.98

Location: Package overview

From: ?npm/siwe@3.0.0npm/apg-js@4.4.0

ℹ Read more on: This package | This alert | What is obfuscated code?

Next steps: Take a moment to review the security alert above. Review the linked package source code to understand the potential risk. Ensure the package is not malicious before proceeding. If you're unsure how to proceed, reach out to your security team or ask the Socket team for help at support@socket.dev.

Suggestion: Packages should not obfuscate their code. Consider not using packages with obfuscated code.

Mark the package as acceptable risk. To ignore this alert only in this pull request, reply with the comment @SocketSecurity ignore npm/apg-js@4.4.0. You can also ignore all packages with @SocketSecurity ignore-all. To ignore an alert for all future pull requests, use Socket's Dashboard to change the triage state of this alert.

Warn High
Obfuscated code: npm buffer is 96.0% likely obfuscated

Confidence: 0.96

Location: Package overview

From: ?npm/aws-sdk@2.1692.0npm/buffer@4.9.2

ℹ Read more on: This package | This alert | What is obfuscated code?

Next steps: Take a moment to review the security alert above. Review the linked package source code to understand the potential risk. Ensure the package is not malicious before proceeding. If you're unsure how to proceed, reach out to your security team or ask the Socket team for help at support@socket.dev.

Suggestion: Packages should not obfuscate their code. Consider not using packages with obfuscated code.

Mark the package as acceptable risk. To ignore this alert only in this pull request, reply with the comment @SocketSecurity ignore npm/buffer@4.9.2. You can also ignore all packages with @SocketSecurity ignore-all. To ignore an alert for all future pull requests, use Socket's Dashboard to change the triage state of this alert.

Warn High
Protestware or unwanted behavior: npm es5-ext

Note: This package prints a protestware console message on install regarding Ukraine for users with Russian language locale

From: ?npm/websocket@1.0.35npm/es5-ext@0.10.64

ℹ Read more on: This package | This alert | What is protestware?

Next steps: Take a moment to review the security alert above. Review the linked package source code to understand the potential risk. Ensure the package is not malicious before proceeding. If you're unsure how to proceed, reach out to your security team or ask the Socket team for help at support@socket.dev.

Suggestion: Consider that consuming this package may come along with functionality unrelated to its primary purpose.

Mark the package as acceptable risk. To ignore this alert only in this pull request, reply with the comment @SocketSecurity ignore npm/es5-ext@0.10.64. You can also ignore all packages with @SocketSecurity ignore-all. To ignore an alert for all future pull requests, use Socket's Dashboard to change the triage state of this alert.

Warn High
Protestware or unwanted behavior: npm es5-ext

Note: The script attempts to run a local post-install script, which could potentially contain malicious code. The error handling suggests that it is designed to fail silently, which is a common tactic in malicious scripts.

From: ?npm/websocket@1.0.35npm/es5-ext@0.10.64

ℹ Read more on: This package | This alert | What is protestware?

Next steps: Take a moment to review the security alert above. Review the linked package source code to understand the potential risk. Ensure the package is not malicious before proceeding. If you're unsure how to proceed, reach out to your security team or ask the Socket team for help at support@socket.dev.

Suggestion: Consider that consuming this package may come along with functionality unrelated to its primary purpose.

Mark the package as acceptable risk. To ignore this alert only in this pull request, reply with the comment @SocketSecurity ignore npm/es5-ext@0.10.64. You can also ignore all packages with @SocketSecurity ignore-all. To ignore an alert for all future pull requests, use Socket's Dashboard to change the triage state of this alert.

View full report

@EmilFattakhov
Copy link
Member Author

Closed as replaced by #587

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