diff --git a/docs/agents/task-logs/daily/2026-02-19_const-refactor-agent_completed.md b/docs/agents/task-logs/daily/2026-02-19_const-refactor-agent_completed.md new file mode 100644 index 00000000..9066386b --- /dev/null +++ b/docs/agents/task-logs/daily/2026-02-19_const-refactor-agent_completed.md @@ -0,0 +1,15 @@ +# Daily Task: const-refactor-agent + +**Date:** 2026-02-19 +**Agent:** const-refactor-agent +**Status:** Completed + +## Actions Taken +- Identified `5000` usage in `js/subscriptions.js` as a candidate for `SHORT_TIMEOUT_MS`. +- Verified `SHORT_TIMEOUT_MS` exists in `js/constants.js` (value: 5000). +- Updated `perf/constants-refactor/candidates.json` with the new finding. +- Refactored `js/subscriptions.js` to import `SHORT_TIMEOUT_MS` and use it for `nip07DecryptTimeoutMs` fallback. +- Verified changes with `npm run lint` and `npm run test:unit`. + +## Findings +- `js/subscriptions.js` uses `12000` for interactive timeout, while `js/userBlocks.js` uses `15000`. This inconsistency remains but the silent fallback is now canonicalized to `SHORT_TIMEOUT_MS` in `subscriptions.js`. diff --git a/js/subscriptions.js b/js/subscriptions.js index 420a6071..15baab96 100644 --- a/js/subscriptions.js +++ b/js/subscriptions.js @@ -36,6 +36,7 @@ import { NIP07_PRIORITY, } from "./nostr/nip07Permissions.js"; import { relaySubscriptionService } from "./services/relaySubscriptionService.js"; +import { SHORT_TIMEOUT_MS } from "./constants.js"; import { getLastSuccessfulScheme, setLastSuccessfulScheme, @@ -1093,7 +1094,9 @@ class SubscriptionsManager { // gate now guarantees the extension is ready before decryption starts, so // decrypt calls should complete within 1-2s. 5s accommodates slow // extensions while still failing fast enough for scheme fallback. - const nip07DecryptTimeoutMs = allowPermissionPrompt ? 12000 : 5000; + const nip07DecryptTimeoutMs = allowPermissionPrompt + ? 12000 + : SHORT_TIMEOUT_MS; const signerDecryptOptions = { priority: NIP07_PRIORITY.NORMAL, timeoutMs: nip07DecryptTimeoutMs, diff --git a/perf/constants-refactor/candidates.json b/perf/constants-refactor/candidates.json index dae3b8b0..df39e83f 100644 --- a/perf/constants-refactor/candidates.json +++ b/perf/constants-refactor/candidates.json @@ -1,13 +1,13 @@ [ { - "value": 10000, - "semantic": "STANDARD_TIMEOUT_MS", + "value": 5000, + "semantic": "SHORT_TIMEOUT_MS", "occurrences": [ - {"file": "js/testHarness.js", "line": 211, "context": "timeoutMs = 10000"}, - {"file": "js/nostr/relayBatchFetcher.js", "line": 19, "context": "timeoutMs = 10000"}, - {"file": "js/nostr/relayBatchFetcher.js", "line": 135, "context": "timeoutMs : 10000"}, - {"file": "js/nostr/client.js", "line": 812, "context": "timeoutMs = 10000"}, - {"file": "js/nostr/client.js", "line": 1425, "context": "timeoutMs || 10000"} + { + "file": "js/subscriptions.js", + "line": 1184, + "context": "nip07DecryptTimeoutMs = allowPermissionPrompt ? 12000 : 5000" + } ] } ] diff --git a/perf/constants-refactor/raw-numeric-hits.txt b/perf/constants-refactor/raw-numeric-hits.txt new file mode 100644 index 00000000..e69de29b