mirror of
https://github.com/PR0M3TH3AN/bitvid.git
synced 2026-10-27 07:52:24 +00:00
refactor: replace magic number 5000 with SHORT_TIMEOUT_MS in js/subscriptions.js
Also updates perf/constants-refactor/candidates.json and adds completion log. Co-authored-by: PR0M3TH3AN <[email protected]>
This commit is contained in:
1 parent
8181588f50
commit
15d28cdf35
4 files changed
+26
-8
No files matched your search
@@ -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`.
|
||||
+4
-1
@@ -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,
|
||||
|
||||
@@ -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"
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
Whitespace-only changes.
Reference in new issue
Block a user