diff --git a/dist/browser/helia/helia-for-pkc.js b/dist/browser/helia/helia-for-pkc.js index e6821667b0601ac56a850e989bfedf76c14796a2..1a2ae7ab9b0afc605c9b4dcddccf25ac02aa1337 100644 --- a/dist/browser/helia/helia-for-pkc.js +++ b/dist/browser/helia/helia-for-pkc.js @@ -145,6 +145,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", { @@ -290,8 +295,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 { @@ -314,7 +324,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(); diff --git a/dist/browser/publications/publication.js b/dist/browser/publications/publication.js index 5e17c02a39c2715c7ac932695fe90d5078bce405..2d43d996e2b3cdab759e89c296eb9ed8aae857db 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/runtime/browser/libp2p-extra-transports.js b/dist/browser/runtime/browser/libp2p-extra-transports.js index 1b7028978d1da8c3f78e9b4d18e790a3ad025e25..2b8eff3ce509cff57ac5be3d31b26b38a5301a52 100644 --- a/dist/browser/runtime/browser/libp2p-extra-transports.js +++ b/dist/browser/runtime/browser/libp2p-extra-transports.js @@ -1,3 +1,4 @@ -const extraLibp2pTransports = []; +import { webTransport } from "@libp2p/webtransport"; +const extraLibp2pTransports = typeof globalThis.WebTransport === "function" ? [webTransport()] : []; export default extraLibp2pTransports; //# sourceMappingURL=libp2p-extra-transports.js.map diff --git a/package.json b/package.json index 2a44f27220191ee556a317bf25005b7fcbde6aaa..335ee82cc7e9850eb1bc036b2a481ae5a575eabd 100644 --- a/package.json +++ b/package.json @@ -78,6 +78,7 @@ "@libp2p/identify": "4.1.3", "@libp2p/interface": "3.2.2", "@libp2p/peer-id": "6.0.8", + "@libp2p/webtransport": "6.0.0", "@multiformats/multiaddr": "13.0.1", "@noble/curves": "2.2.0", "@pkcprotocol/pkc-logger": "0.1.0",