From b8832dcae86c3b803de5c779b4a4aa4fdf996162 Mon Sep 17 00:00:00 2001 From: "google-labs-jules[bot]" <161369871+google-labs-jules[bot]@users.noreply.github.com> Date: Tue, 17 Feb 2026 07:58:40 +0000 Subject: [PATCH] perf: bound DM subsystem network concurrency & fix CI lint buffer - Replaced unbounded `Promise.all` with `pMap` and `RELAY_BACKGROUND_CONCURRENCY || 3` in `js/nostr/dmSignalEvents.js` and `js/services/dmNostrService.js` to prevent network saturation. - Increased `maxBuffer` in `scripts/check-hex.js` to 10MB to prevent `ENOBUFS` when git text search matches large minified files in CI. - Verified documentation in `content/docs/guides/upload-content.md` correctly specifies port 3000. - Passed all unit and integration tests. Co-authored-by: PR0M3TH3AN <53631862+PR0M3TH3AN@users.noreply.github.com> --- daily-perf-report-2026-02-17.md | 10 +++++++--- .../daily/2026-02-17_07-39-33_perf-agent_completed.md | 7 +++++-- js/nostr/dmSignalEvents.js | 4 ++-- js/services/dmNostrService.js | 4 ++-- scripts/check-hex.js | 3 ++- 5 files changed, 18 insertions(+), 10 deletions(-) diff --git a/daily-perf-report-2026-02-17.md b/daily-perf-report-2026-02-17.md index a510ffbd..890a3e93 100644 --- a/daily-perf-report-2026-02-17.md +++ b/daily-perf-report-2026-02-17.md @@ -1,6 +1,6 @@ # Daily Performance Report - 2026-02-17 -**Summary:** Bounded concurrency for DM signal events and DM service initialization to prevent network saturation. +**Summary:** Bounded concurrency for DM signal events and DM service initialization to prevent network saturation. Also fixed a CI failure related to `lint:hex` buffer size. ## Findings & Fixes @@ -10,6 +10,10 @@ - **Fix:** Replaced with `pMap` using `RELAY_BACKGROUND_CONCURRENCY` (3). - **Verification:** `npm run test:dm:unit` and `npm run test:dm:integration` passed. +### CI Failure (lint:hex) +- **Problem:** The `npm run lint:hex` script failed in CI with exit code 1 (and likely `ENOBUFS` internally) because `git grep` outputted large minified file contents that exceeded the default buffer size of `spawnSync`. +- **Fix:** Increased `maxBuffer` in `scripts/check-hex.js` to 10MB. + ### Docs Audit - **Port Alignment:** Verified `content/docs/guides/upload-content.md` correctly specifies port 3000 for CORS, aligning with previous remediation. No changes needed. @@ -18,7 +22,7 @@ - **DM Decrypt Queue:** N/A (network bounding). ## Decisions -- Used `RELAY_BACKGROUND_CONCURRENCY` (3) for DM operations to match relay manager behavior. +- Used `RELAY_BACKGROUND_CONCURRENCY || 3` for DM operations to match relay manager behavior and ensure robustness. ## PRs / Commits -- `perf: bound DM subsystem network concurrency` (this change). +- `perf: bound DM subsystem network concurrency & fix CI lint buffer` diff --git a/docs/agents/task-logs/daily/2026-02-17_07-39-33_perf-agent_completed.md b/docs/agents/task-logs/daily/2026-02-17_07-39-33_perf-agent_completed.md index d956350c..888af0d6 100644 --- a/docs/agents/task-logs/daily/2026-02-17_07-39-33_perf-agent_completed.md +++ b/docs/agents/task-logs/daily/2026-02-17_07-39-33_perf-agent_completed.md @@ -5,16 +5,19 @@ **Goals:** - Identify and fix unbounded concurrency in network operations. - Audit upload documentation. +- Fix CI failures. **Actions:** - **Identified:** Unbounded `Promise.all` usage in `js/nostr/dmSignalEvents.js` and `js/services/dmNostrService.js`. -- **Fixed:** Replaced with `pMap` and `RELAY_BACKGROUND_CONCURRENCY` (3). +- **Fixed:** Replaced with `pMap` and `RELAY_BACKGROUND_CONCURRENCY || 3`. +- **Fixed CI:** Increased `maxBuffer` in `scripts/check-hex.js` to 10MB to prevent `ENOBUFS` when `git grep` matches large minified files. - **Verified:** Documentation in `content/docs/guides/upload-content.md` correctly specifies port 3000. -- **Tested:** Unit and integration tests for DM subsystem passed. +- **Tested:** Unit and integration tests for DM subsystem passed. Lint passed. **Files Changed:** - `js/nostr/dmSignalEvents.js` - `js/services/dmNostrService.js` +- `scripts/check-hex.js` - `daily-perf-report-2026-02-17.md` - Context/Logs: `context/`, `todo/`, `decisions/`, `test_logs/` diff --git a/js/nostr/dmSignalEvents.js b/js/nostr/dmSignalEvents.js index 55f1aba6..23d83442 100644 --- a/js/nostr/dmSignalEvents.js +++ b/js/nostr/dmSignalEvents.js @@ -144,7 +144,7 @@ export async function publishDmReadReceipt( const publishResults = await pMap( relayList, (url) => publishEventToRelay(client.pool, url, signedEvent), - { concurrency: RELAY_BACKGROUND_CONCURRENCY }, + { concurrency: RELAY_BACKGROUND_CONCURRENCY || 3 }, ); const acceptedRelays = publishResults @@ -287,7 +287,7 @@ export async function publishDmTypingIndicator( const publishResults = await pMap( relayList, (url) => publishEventToRelay(client.pool, url, signedEvent), - { concurrency: RELAY_BACKGROUND_CONCURRENCY }, + { concurrency: RELAY_BACKGROUND_CONCURRENCY || 3 }, ); const acceptedRelays = publishResults diff --git a/js/services/dmNostrService.js b/js/services/dmNostrService.js index 6b2113f7..8e02ae51 100644 --- a/js/services/dmNostrService.js +++ b/js/services/dmNostrService.js @@ -279,7 +279,7 @@ class DmNostrService { async (relayUrl) => { await this.connectRelay(relayUrl); }, - { concurrency: RELAY_BACKGROUND_CONCURRENCY }, + { concurrency: RELAY_BACKGROUND_CONCURRENCY || 3 }, ); } @@ -680,7 +680,7 @@ class DmNostrService { return { ...result, relayUrl }; }, - { concurrency: RELAY_BACKGROUND_CONCURRENCY }, + { concurrency: RELAY_BACKGROUND_CONCURRENCY || 3 }, ); return results; diff --git a/scripts/check-hex.js b/scripts/check-hex.js index ee1a56b3..46cf96ad 100755 --- a/scripts/check-hex.js +++ b/scripts/check-hex.js @@ -55,7 +55,8 @@ for (const glob of IGNORED_GLOBS) { // We rely on 'git' being available and 'git grep' supporting -P. // Typically available in most CI/dev environments. -const result = spawnSync('git', gitArgs, { encoding: 'utf8' }); +// Increase maxBuffer to 10MB to prevent ENOBUFS on large minified files +const result = spawnSync('git', gitArgs, { encoding: 'utf8', maxBuffer: 10 * 1024 * 1024 }); if (result.error) { console.error('Failed to execute git grep:', result.error.message);