mirror of
https://github.com/PR0M3TH3AN/bitvid.git
synced 2026-11-04 20:02:26 +00:00
fix(ci): prevent signer hangs in tests and background services
Co-authored-by: PR0M3TH3AN <[email protected]>
This commit is contained in:
1 parent
a920032993
commit
eeb3283344
2 files changed
+25
-5
No files matched your search
@@ -74,7 +74,7 @@ function getSessionActorKey() {
|
||||
return normalizeActorKey(nostrClient?.sessionActor?.pubkey);
|
||||
}
|
||||
|
||||
async function ensureWatchHistoryExtensionPermissions(actorKey) {
|
||||
async function ensureWatchHistoryExtensionPermissions(actorKey, options = {}) {
|
||||
const normalizedActor = normalizeActorKey(actorKey);
|
||||
if (!normalizedActor) {
|
||||
return { ok: true };
|
||||
@@ -85,8 +85,13 @@ async function ensureWatchHistoryExtensionPermissions(actorKey) {
|
||||
return { ok: true };
|
||||
}
|
||||
|
||||
const allowPermissionPrompt = options?.allowPermissionPrompt !== false;
|
||||
|
||||
let signer = getActiveSigner();
|
||||
if (!signer && typeof nostrClient?.ensureActiveSignerForPubkey === "function") {
|
||||
if (
|
||||
allowPermissionPrompt &&
|
||||
(!signer && typeof nostrClient?.ensureActiveSignerForPubkey === "function")
|
||||
) {
|
||||
signer = await nostrClient.ensureActiveSignerForPubkey(normalizedActor);
|
||||
}
|
||||
|
||||
@@ -97,6 +102,10 @@ async function ensureWatchHistoryExtensionPermissions(actorKey) {
|
||||
return { ok: true };
|
||||
}
|
||||
|
||||
if (!allowPermissionPrompt) {
|
||||
return { ok: true };
|
||||
}
|
||||
|
||||
const permissionResult = await requestDefaultExtensionPermissions();
|
||||
if (permissionResult.ok) {
|
||||
return { ok: true };
|
||||
@@ -984,7 +993,7 @@ async function snapshot(items, options = {}) {
|
||||
return run;
|
||||
}
|
||||
|
||||
function scheduleWatchHistoryRefresh(actorKey, cacheEntry = {}) {
|
||||
function scheduleWatchHistoryRefresh(actorKey, cacheEntry = {}, options = {}) {
|
||||
if (!actorKey) {
|
||||
return Promise.resolve([]);
|
||||
}
|
||||
@@ -996,6 +1005,7 @@ function scheduleWatchHistoryRefresh(actorKey, cacheEntry = {}) {
|
||||
const promise = (async () => {
|
||||
const permissionResult = await ensureWatchHistoryExtensionPermissions(
|
||||
actorKey,
|
||||
options
|
||||
);
|
||||
if (!permissionResult.ok) {
|
||||
throw permissionResult.error;
|
||||
@@ -1264,11 +1274,19 @@ async function loadLatest(actorInput, options = {}) {
|
||||
}
|
||||
|
||||
if (!allowStale || !hasCachedItems) {
|
||||
const resolved = await scheduleWatchHistoryRefresh(actorKey, cacheEntry);
|
||||
const resolved = await scheduleWatchHistoryRefresh(
|
||||
actorKey,
|
||||
cacheEntry,
|
||||
normalizedOptions
|
||||
);
|
||||
return mergeQueuedItemsIfNeeded(actorKey, resolved);
|
||||
}
|
||||
|
||||
const refreshPromise = scheduleWatchHistoryRefresh(actorKey, cacheEntry);
|
||||
const refreshPromise = scheduleWatchHistoryRefresh(
|
||||
actorKey,
|
||||
cacheEntry,
|
||||
normalizedOptions
|
||||
);
|
||||
refreshPromise.catch(() => {});
|
||||
|
||||
devLogger.info(
|
||||
|
||||
@@ -67,6 +67,8 @@ test.after(() => {
|
||||
} else {
|
||||
globalThis.NostrTools = originalGlobalNostrTools;
|
||||
}
|
||||
// Force exit to prevent hanging handles from singletons
|
||||
setTimeout(() => process.exit(0), 100);
|
||||
});
|
||||
|
||||
function createServiceWithAccessControl() {
|
||||
|
||||
Reference in new issue
Block a user