Optimize application startup speed by parallelizing initialization

This commit is contained in:
google-labs-jules[bot] committed 2026-01-13 04:21:13 +00:00
1 parent e1d43708c5
commit 29857dc36c
2 files changed
+24 -15

No files matched your search

+11 -13
View File
@@ -433,22 +433,20 @@ class AccessControl {
}
async ensureReady() {
// If not loaded and not already refreshing, kick off a background refresh.
// We do NOT await this promise, allowing the application to proceed immediately.
// Reactive updates (e.g. onBlacklistChange) will handle the UI state when data arrives.
if (!this.hasLoaded && !this._isRefreshing) {
this.refresh();
this.refresh().catch((error) => {
userLogger.warn(
"[accessControl] Background refresh failed:",
error,
);
});
}
try {
await this._refreshPromise;
userLogger.info("[accessControl] ensureReady resolved");
} catch (error) {
if (!this.hasLoaded) {
userLogger.warn("[accessControl] ensureReady retry");
await this.refresh();
await this._refreshPromise;
} else {
throw error;
}
}
// Always resolve immediately to prevent blocking application startup.
return Promise.resolve();
}
whitelistMode() {
+13 -2
View File
@@ -436,9 +436,20 @@ class Application {
profileModalPromise,
]);
const nostrInitPromise = nostrClient.init();
// Initialize the pool early to unblock bootstrapTrustedSeeds,
// but do NOT await the full connection process here.
try {
await nostrClient.ensurePool();
} catch (poolError) {
devLogger.warn("[app.init()] Pool ensure failed:", poolError);
}
await Promise.all([modalBootstrapPromise, nostrInitPromise]);
// Kick off relay connection in the background.
const nostrInitPromise = nostrClient.init().catch((err) => {
devLogger.warn("[app.init()] Background nostrClient.init failed:", err);
});
await modalBootstrapPromise;
try {
await bootstrapTrustedSeeds();