mirror of
https://github.com/PR0M3TH3AN/bitvid.git
synced 2026-11-02 02:42:28 +00:00
fix(ci): resolve e2e timeouts and add app init safeguards
- Add `firefox` to `npx playwright install` in CI workflow to fix headless execution failures. - Implement 15s safeguard timeout in `js/app.js` for `_initAccessControl` to prevent app hang during startup. - Add `SHORT_TIMEOUT_MS` (5s) to `fetchLatestListEvent` in `js/adminListStore.js` to prevent indefinite hanging on relay queries. - Update `tests/admin-list-store.test.mjs` to force dev mode for warning assertions. Co-authored-by: PR0M3TH3AN <[email protected]>
This commit is contained in:
1 parent
1bf491a999
commit
8257a94925
2 files changed
+33
-10
No files matched your search
+31
-10
@@ -9,6 +9,7 @@ import {
|
||||
ADMIN_COMMUNITY_BLACKLIST_PREFIX,
|
||||
isDevMode,
|
||||
} from "./config.js";
|
||||
import { SHORT_TIMEOUT_MS } from "./constants.js";
|
||||
import {
|
||||
getRegisteredNostrClient,
|
||||
requestDefaultExtensionPermissions,
|
||||
@@ -549,22 +550,42 @@ async function fetchLatestListEvent(filter, contextLabel = "admin-list") {
|
||||
}
|
||||
|
||||
let events = [];
|
||||
if (pubkey) {
|
||||
events = await nostrClient.fetchListIncrementally({
|
||||
kind,
|
||||
pubkey,
|
||||
dTag,
|
||||
relayUrls: relays
|
||||
});
|
||||
} else {
|
||||
const timeoutPromise = new Promise((_, reject) => {
|
||||
setTimeout(() => {
|
||||
reject(createError("timeout", "Request timed out"));
|
||||
}, SHORT_TIMEOUT_MS);
|
||||
});
|
||||
|
||||
try {
|
||||
if (pubkey) {
|
||||
events = await Promise.race([
|
||||
nostrClient.fetchListIncrementally({
|
||||
kind,
|
||||
pubkey,
|
||||
dTag,
|
||||
relayUrls: relays,
|
||||
}),
|
||||
timeoutPromise,
|
||||
]);
|
||||
} else {
|
||||
// Fallback for non-specific queries
|
||||
const normalizedFilter = {
|
||||
kinds: [kind],
|
||||
limit: 50
|
||||
limit: 50,
|
||||
};
|
||||
if (dTag) normalizedFilter["#d"] = [dTag];
|
||||
if (filter.authors) normalizedFilter.authors = filter.authors;
|
||||
events = await nostrClient.pool.list(relays, [normalizedFilter]);
|
||||
events = await Promise.race([
|
||||
nostrClient.pool.list(relays, [normalizedFilter]),
|
||||
timeoutPromise,
|
||||
]);
|
||||
}
|
||||
} catch (error) {
|
||||
devLogger.warn(
|
||||
`[adminListStore] Fetch failed for ${contextLabel}:`,
|
||||
error,
|
||||
);
|
||||
throw error;
|
||||
}
|
||||
|
||||
if (!events || !events.length) {
|
||||
|
||||
@@ -3,6 +3,8 @@
|
||||
import "./test-helpers/setup-localstorage.mjs";
|
||||
import assert from "node:assert/strict";
|
||||
|
||||
globalThis.__BITVID_DEV_MODE_OVERRIDE__ = true;
|
||||
|
||||
if (typeof globalThis.window === "undefined") {
|
||||
globalThis.window = {};
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user