Merge pull request #2600 from PR0M3TH3AN/agents-daily-const-refactor-20260217-13915779622347863588

Refactor constant timeouts in subscriptions and userBlocks
This commit is contained in:
thePR0M3TH3AN authored and GitHub committed 2026-02-17 17:04:25 -05:00
commit 9918610426
9 files changed
+55 -4

No files matched your search

+1
View File
@@ -0,0 +1 @@
# Context for Constants Refactor\n\nTimestamp: 20260217_205312\nBranch: unstable\nCommit: 65d82e578faf6c46ee7d2b6c61d93105c6f4c855\nNode: v22.22.0\nNPM: 11.7.0\n\nGoal: Find duplicated numeric constants in js/ and replace with canonical definitions.
+7
View File
@@ -0,0 +1,7 @@
# Decisions for Constants Refactor
- **5000ms timeout in `js/subscriptions.js`**: Replaced with `SHORT_TIMEOUT_MS` from `js/constants.js`. The usage matches the definition of a "short timeout" for background operations or quick fallbacks.
- **10000ms timeout in `js/userBlocks.js`**: Replaced with `STANDARD_TIMEOUT_MS` from `js/constants.js`. The usage is for a fetch operation which aligns with the standard timeout definition.
Alternatives considered:
- Creating specific constants like `NIP07_SHORT_TIMEOUT_MS`. Rejected because `SHORT_TIMEOUT_MS` is generic enough and already used for similar purposes.
@@ -0,0 +1,19 @@
# Agent Run: const-refactor-agent
**Status:** Completed
**Timestamp:** 2026-02-17 20:53:12
**Agent:** const-refactor-agent
**Cadence:** daily
## Summary
Replaced duplicated numeric constants with canonical definitions.
- Replaced `5000` with `SHORT_TIMEOUT_MS` in `js/subscriptions.js`.
- Replaced `timeoutMs: 10000` with `timeoutMs: STANDARD_TIMEOUT_MS` in `js/userBlocks.js`.
## Artifacts
- `context/CONTEXT_20260217_205312.md`
- `todo/TODO_20260217_205312.md`
- `decisions/DECISIONS_20260217_205312.md`
- `test_logs/TEST_LOG_20260217_205312.md`
- `perf/constants-refactor/candidates.json`
+2 -1
View File
@@ -26,6 +26,7 @@ import {
import { getApplication } from "./applicationContext.js";
import { VideoListView } from "./ui/views/VideoListView.js";
import { ALLOW_NSFW_CONTENT } from "./config.js";
import { SHORT_TIMEOUT_MS } from "./constants.js";
import { devLogger, userLogger } from "./utils/logger.js";
import moderationService from "./services/moderationService.js";
import nostrService from "./services/nostrService.js";
@@ -1093,7 +1094,7 @@ 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,
+1 -1
View File
@@ -1558,7 +1558,7 @@ class UserBlockListManager {
pubkey: normalized,
relayUrls: relays,
since: fetchSince,
timeoutMs: 10000,
timeoutMs: STANDARD_TIMEOUT_MS,
});
const legacyFetchPromise = Promise.all([
+12 -2
View File
@@ -1,4 +1,12 @@
[
{
"value": 5000,
"semantic": "short timeout",
"occurrences": [
{ "file": "js/subscriptions.js", "line": 1096, "context": "nip07DecryptTimeoutMs" }
],
"canonical": { "name": "SHORT_TIMEOUT_MS", "file": "js/constants.js" }
},
{
"value": 10000,
"semantic": "STANDARD_TIMEOUT_MS",
@@ -7,7 +15,9 @@
{"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/nostr/client.js", "line": 1425, "context": "timeoutMs || 10000"},
{ "file": "js/userBlocks.js", "line": 1561, "context": "timeoutMs" }
],
"canonical": { "name": "STANDARD_TIMEOUT_MS", "file": "js/constants.js" }
}
]
Whitespace-only changes.
+7
View File
@@ -0,0 +1,7 @@
# Test Log
## Lint
Passed.
## Unit Tests
Passed. All unit tests executed successfully.
+6
View File
@@ -0,0 +1,6 @@
# TODO List for Constants Refactor
- [x] Identify duplicates for 5000ms (SHORT_TIMEOUT_MS) in js/subscriptions.js
- [x] Identify duplicates for 10000ms (STANDARD_TIMEOUT_MS) in js/userBlocks.js
- [x] Replace with canonical constants
- [x] Verify with lint and tests