diff --git a/dist/browser/publications/publication.js b/dist/browser/publications/publication.js index 5e17c02a39c2715c7ac932695fe90d5078bce405..339d299de85ba5d144e4608f9189c88f4ef42dc8 100644 --- a/dist/browser/publications/publication.js +++ b/dist/browser/publications/publication.js @@ -842,8 +842,14 @@ class Publication extends TypedEmitter { await new Promise((resolve) => setTimeout(resolve, this._setProviderFailureThresholdSeconds * 1000)); if (this._isAllAttemptsExhausted(providers.length)) { await this._postSucessOrFailurePublishing(); - const allAttemptsFailedError = new PKCError("ERR_ALL_PUBSUB_PROVIDERS_THROW_ERRORS", { - challengeExchanges: this._challengeExchangesFormattedForErrors(), + const challengeExchanges = this._challengeExchangesFormattedForErrors(); + const didEveryAttemptThrow = challengeExchanges.length > 0 && + challengeExchanges.every((exchange) => exchange.challengeRequestPublishError); + const allAttemptsFailedError = new PKCError(didEveryAttemptThrow + ? "ERR_ALL_PUBSUB_PROVIDERS_THROW_ERRORS" + : "ERR_PUBSUB_DID_NOT_RECEIVE_RESPONSE_AFTER_PUBLISHING_CHALLENGE_REQUEST", { + challengeExchanges, + publishToDifferentProviderThresholdSeconds: this._publishToDifferentProviderThresholdSeconds, pubsubTopic: this._communityPubsubTopicWithFallback(), providerHeliaContexts: this._libp2pJsClientHeliaContexts() }); diff --git a/dist/browser/helia/helia-for-pkc.js b/dist/browser/helia/helia-for-pkc.js index 3eca64dd532a19393c55ddf953dfd4ef207c65f8..683fed56722effc54b1b08e5b050e311ed174424 100644 --- a/dist/browser/helia/helia-for-pkc.js +++ b/dist/browser/helia/helia-for-pkc.js @@ -161,6 +161,11 @@ export async function createLibp2pJsClientOrUseExistingOne(pkcOptions) { warmupPromisesByTopic.set(topic, p); return p; }; + const ignoreBestEffortPubsubWarmupError = (operation, topic, err, options) => { + if (options?.signal?.aborted) + throw err; + log.error(`Best-effort pubsub peer warmup failed before ${operation} on topic`, topic, err); + }; const throwIfHeliaIsStoppingOrStopped = () => { if (helia.libp2p.status === "stopped" || helia.libp2p.status === "stopping") throw new PKCError("ERR_HELIAS_STOPPING_OR_STOPPED", { @@ -299,8 +304,13 @@ export async function createLibp2pJsClientOrUseExistingOne(pkcOptions) { if (!wasAlreadySubscribed) helia.libp2p.services.pubsub.subscribe(topic); try { - await warmupForTopic(topic, options); - const res = await helia.libp2p.services.pubsub.publish(topic, data); + try { + await warmupForTopic(topic, options); + } + catch (err) { + ignoreBestEffortPubsubWarmupError("publish", topic, err, options); + } + const res = await helia.libp2p.services.pubsub.publish(topic, data, { allowPublishToZeroTopicPeers: true }); log("Published new data to pubsub topic (string, e.g. community address)", topic, "Direct gossipsub recipients (libp2p peer IDs, NOT signer/community addresses):", res.recipients.map((p) => p.toString())); } finally { @@ -323,7 +333,12 @@ export async function createLibp2pJsClientOrUseExistingOne(pkcOptions) { // locally subscribed to). const warmupPromise = warmupForTopic(topic, options); helia.libp2p.services.pubsub.subscribe(topic); - await warmupPromise; + try { + await warmupPromise; + } + catch (err) { + ignoreBestEffortPubsubWarmupError("subscribe", topic, err, options); + } }, unsubscribe: async (topic, handler, options) => { throwIfHeliaIsStoppingOrStopped();