@pkcprotocol/pkc-js 0.0.82 → 0.0.84

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (74) hide show
  1. package/README.md +16 -0
  2. package/dist/browser/community/rpc-remote-community.js +15 -8
  3. package/dist/browser/community/rpc-remote-community.js.map +1 -1
  4. package/dist/browser/community/schema.js +3 -1
  5. package/dist/browser/community/schema.js.map +1 -1
  6. package/dist/browser/errors.d.ts +3 -0
  7. package/dist/browser/errors.js +3 -0
  8. package/dist/browser/errors.js.map +1 -1
  9. package/dist/browser/generated-version.d.ts +1 -1
  10. package/dist/browser/generated-version.js +1 -1
  11. package/dist/browser/pkc/pkc-with-rpc-client.d.ts +5 -3
  12. package/dist/browser/pkc/pkc-with-rpc-client.js +45 -7
  13. package/dist/browser/pkc/pkc-with-rpc-client.js.map +1 -1
  14. package/dist/browser/pkc/pkc.d.ts +6 -3
  15. package/dist/browser/pkc/pkc.js +71 -9
  16. package/dist/browser/pkc/pkc.js.map +1 -1
  17. package/dist/browser/pkc-error.d.ts +1 -1
  18. package/dist/browser/publications/comment/schema.d.ts +1 -1
  19. package/dist/browser/publications/comment/schema.js +5 -1
  20. package/dist/browser/publications/comment/schema.js.map +1 -1
  21. package/dist/browser/publications/publication-client-manager.js +10 -2
  22. package/dist/browser/publications/publication-client-manager.js.map +1 -1
  23. package/dist/browser/publications/publication.d.ts +4 -0
  24. package/dist/browser/publications/publication.js +36 -2
  25. package/dist/browser/publications/publication.js.map +1 -1
  26. package/dist/browser/runtime/node/community/db-handler.d.ts +2 -0
  27. package/dist/browser/runtime/node/community/db-handler.js +21 -4
  28. package/dist/browser/runtime/node/community/db-handler.js.map +1 -1
  29. package/dist/browser/types.d.ts +5 -0
  30. package/dist/browser/util.d.ts +20 -1
  31. package/dist/browser/util.js +100 -2
  32. package/dist/browser/util.js.map +1 -1
  33. package/dist/bundled/bundle-manifest.json +25 -25
  34. package/dist/bundled/chunks/{helia-for-pkc-CQY3-UYD.js → helia-for-pkc-BlDudTLN.js} +2 -2
  35. package/dist/bundled/chunks/{local-community-AZAEiiht.js → local-community-4wIeaqty.js} +1 -1
  36. package/dist/bundled/chunks/{local-community-DRm3r1-Y.js → local-community-5PMI-TDB.js} +15 -6
  37. package/dist/bundled/chunks/{node-B1J8psGZ.js → node-B7GkmuSc.js} +110 -22
  38. package/dist/bundled/chunks/{rpc-local-community-0XmKyOdO.js → rpc-local-community-r51cTBYd.js} +16 -10
  39. package/dist/bundled/chunks/{schema-BUUhufdT.js → schema-AXrL86Q4.js} +79 -6
  40. package/dist/bundled/chunks/{util-Cct7-RT3.js → util-CwzCEPKs.js} +1 -1
  41. package/dist/bundled/index.js +1 -1
  42. package/dist/bundled/rpc/src/index.js +4 -4
  43. package/dist/node/community/rpc-remote-community.js +15 -8
  44. package/dist/node/community/rpc-remote-community.js.map +1 -1
  45. package/dist/node/community/schema.js +3 -1
  46. package/dist/node/community/schema.js.map +1 -1
  47. package/dist/node/errors.d.ts +3 -0
  48. package/dist/node/errors.js +3 -0
  49. package/dist/node/errors.js.map +1 -1
  50. package/dist/node/generated-version.d.ts +1 -1
  51. package/dist/node/generated-version.js +1 -1
  52. package/dist/node/pkc/pkc-with-rpc-client.d.ts +5 -3
  53. package/dist/node/pkc/pkc-with-rpc-client.js +45 -7
  54. package/dist/node/pkc/pkc-with-rpc-client.js.map +1 -1
  55. package/dist/node/pkc/pkc.d.ts +6 -3
  56. package/dist/node/pkc/pkc.js +71 -9
  57. package/dist/node/pkc/pkc.js.map +1 -1
  58. package/dist/node/pkc-error.d.ts +1 -1
  59. package/dist/node/publications/comment/schema.d.ts +1 -1
  60. package/dist/node/publications/comment/schema.js +5 -1
  61. package/dist/node/publications/comment/schema.js.map +1 -1
  62. package/dist/node/publications/publication-client-manager.js +10 -2
  63. package/dist/node/publications/publication-client-manager.js.map +1 -1
  64. package/dist/node/publications/publication.d.ts +4 -0
  65. package/dist/node/publications/publication.js +36 -2
  66. package/dist/node/publications/publication.js.map +1 -1
  67. package/dist/node/runtime/node/community/db-handler.d.ts +2 -0
  68. package/dist/node/runtime/node/community/db-handler.js +21 -4
  69. package/dist/node/runtime/node/community/db-handler.js.map +1 -1
  70. package/dist/node/types.d.ts +5 -0
  71. package/dist/node/util.d.ts +20 -1
  72. package/dist/node/util.js +100 -2
  73. package/dist/node/util.js.map +1 -1
  74. package/package.json +1 -1
@@ -1,7 +1,7 @@
1
1
  import { i as __toESM, r as __require, t as __commonJSMin } from "./chunk-2rV9d50f.js";
2
- import { $n as n$1, B as isIpfsCid, Cr as setErrorMap, Ct as findUpdatingCommunity, D as deepMergeRuntimeFields, Dn as CommentUpdateSchema, Dt as refreshTrackedCommentAliases, E as createAbortError, Et as listUpdatingCommunities, Fr as parsedType, H as isIpns, Ir as stringifyPrimitive, It as require_sha256, L as hideClassPrivateProps, Lt as TimeoutError, Pr as joinValues, Pt as untrackUpdatingComment, Q as isStringDomain, Qt as CommunityAnchorSchema, R as ipnsNameToIpnsOverPubsubTopic, Rt as pTimeout, St as findUpdatingComment, Tt as listUpdatingComments, Zn as n$2, _t as timestamp, a as ChallengeRequestMessageSchema, ar as r, b as areEquivalentCommunityAddresses, br as logger_default, ct as resolveWhenPredicateIsTrue, fr as require_retry, ft as shortifyAddress, jt as trackUpdatingComment, k as doesDomainAddressHaveCapitalLetter, ln as PubsubTopicSchema, mt as sleepUntilTimeoutOrAbort, nr as e, ot as removeUndefinedValuesRecursively, pr as FailedToFetchCommentIpfsFromGatewaysError, pt as shortifyCid, r as ChallengeMessageSchema, rn as CommunityIpfsSchema, rr as e$1, s as ChallengeVerificationMessageSchema, st as replaceXWithY, t as ChallengeAnswerMessageSchema, tr as t$1, ut as retryKuboIpfsAdd, vr as PKCError, vt as waitForUpdateInCommunityInstanceWithErrorAndTimeout, wn as CommentUpdateForChallengeVerificationSchema, wt as listStartedCommunities, xt as findStartedCommunity, y as version_default, yn as CommentIpfsSchema, yr as messages, z as isAbortError } from "./schema-BUUhufdT.js";
3
- import { $ as applyNameResolvedCacheToCrosspost, At as verifyCommentModeration, B as tryToDeleteCommunitiesThatFailedToBeDeletedBefore, Bn as RpcExportCommunityModLogsParamSchema, Bt as normalizeCreatePublicationAuthor, Cn as parseDecryptedChallengeVerification, Ct as signVote, Dn as parseRpcCommentEventWithPKCErrorIfItFails, Dt as verifyChallengeVerification, E as createKuboRpcClient, En as parsePKCUserOptionsSchemaWithPKCErrorIfItFails, F as listCommunitiesSync, Fn as RpcCidParamSchema, Ft as verifyVote, Gn as RpcFetchCidResultSchema, Gt as normalizeCommunityInputFromCommunity, Hn as RpcExportCommunityParamSchema, Ht as getCommunityAddressFromRecord, I as monitorCommunitiesDirectory, In as RpcCommentRepliesPageParamSchema, It as buildRuntimeAuthor, J as extractCommunityRuntimeFieldsFromParsedPages, Jn as RpcPublishedAnchorRecordResultSchema, Jt as getBufferedPKCAddressFromPublicKey, Kn as RpcPublishAnchorRecordParamSchema, Kt as decode, Ln as RpcCommunityIdentifierParamSchema, Lt as cleanWireAuthor, M as getDefaultDataPath, Mn as RpcAnchorPublishPreparationResultSchema, Mt as verifyCommentUpdate, Nn as RpcAuthorNameParamSchema, On as parseRpcCommentUpdateEventWithPKCErrorIfItFails, Ot as verifyCommentEdit, Pn as RpcCancelExportParamSchema, Pt as verifyCommunityEdit, Q as RepliesPages, Qn as RpcUnsubscribeParamSchema, Rn as RpcCommunityPageParamSchema, Rt as getAuthorNameFromRuntime, Sn as parseDecryptedChallengeAnswerWithPKCErrorIfItFails, St as signCommunityEdit, Tn as parseJsonWithPKCErrorIfFails, Tt as verifyChallengeMessage, Un as RpcExportCommunityResultSchema, Ut as getCommunityNameFromWire, V as CommentClientsManager, Vn as RpcExportCommunityModLogsResultSchema, Vt as buildRuntimeCommunityFields, Wn as RpcFetchCidParamSchema, Wt as getCommunityPublicKeyFromWire, Xn as RpcSubscriptionIdResultSchema, Y as findCommentInPageInstanceRecursively, Yn as RpcResolveAuthorNameResultSchema, Z as parseRawPages, Zn as RpcSuccessResultSchema, Zt as getPKCAddressFromPublicKeySync, _ as createAnchorIpnsRecord$1, _t as signCommentEdit, a as pkcJsChallenges, ar as n$3, at as PKCClientsManager, b as encryptEd25519AesGcm, bn as parseCreateRpcCommunityFunctionArgumentSchemaWithPKCErrorIfItFails, c as RemoteCommunity, cn as parseCommunityAddressWithPKCErrorIfItFails, cr as t$5, d as decodeRpcChallengeAnswerPubsubMsg, dn as parseCommunityEditPubsubMessagePublicationSchemaWithPKCErrorIfItFails, dt as cleanUpBeforePublishing, en as parseCidStringSchemaWithPKCErrorIfItFails, et as cloneCrosspostForRuntime, f as decodeRpcChallengePubsubMsg, fr as nativeFunctions$2, ft as signChallengeAnswer, g as createSigner, gn as parseCreateCommunityEditPublicationOptionsSchemaWithPKCErrorIfItFails, gt as signComment, hn as parseCreateCommentOptionsSchemaWithPKCErrorIfItFails, in as parseCommentIpfsSchemaWithPKCErrorIfItFails, ir as t$3, it as PublicationClientsManager, jn as parseVotePubsubMessagePublicationSchemaWithPKCErrorIfItFails, jt as verifyCommentPubsubMessage, kn as parseSetNewSettingsPKCWsServerSchemaWithPKCErrorIfItFails, kt as verifyCommentIpfs, lt as PKCTypedEmitter, m as decodeRpcChallengeVerificationPubsubMsg, mn as parseCreateCommentModerationOptionsSchemaWithPKCErrorIfItFails, mt as signChallengeRequest, n as RpcRemoteCommunity, o as TrackedInstanceRegistry, on as parseCommentModerationPubsubMessagePublicationSchemaWithPKCErrorIfItFails, ot as InflightFetchManager, p as decodeRpcChallengeRequestPubsubMsg, pn as parseCreateCommentEditOptionsSchemaWithPKCErrorIfItFails, pr as require_undici, qn as RpcPublishChallengeAnswersParamSchema, rn as parseCommentEditPubsubMessagePublicationSchemaWithPKCErrorIfItFails, rt as stripNameResolvedFromCrosspost, s as LRUCache, sn as parseCommentPubsubMessagePublicationWithPKCErrorIfItFails, sr as t$2, t as RpcLocalCommunity, tr as t$4, tt as collectCrosspostAuthorsToResolve, u as KeyvBetterSqlite3, ut as require_lib$1, v as decryptEd25519AesGcm, vt as signCommentModeration, wn as parseDecryptedChallengeWithPKCErrorIfItFails, xn as parseCreateVoteOptionsSchemaWithPKCErrorIfItFails, yn as parseCreateRemoteCommunityFunctionArgumentSchemaWithPKCErrorIfItFails, z as setNativeFunctions$1, zn as RpcEditCommunityParamSchema } from "./rpc-local-community-0XmKyOdO.js";
4
- import { o as getHeliaDebugContext } from "./util-Cct7-RT3.js";
2
+ import { $n as n$2, B as isIpfsCid, Bt as pTimeout, Ct as findStartedCommunity, D as deepMergeRuntimeFields, Dt as listUpdatingComments, E as createAbortError, En as CommentUpdateForChallengeVerificationSchema, Et as listStartedCommunities, H as isIpns, Ir as joinValues, It as untrackUpdatingComment, L as hideClassPrivateProps, Lr as parsedType, Nt as trackUpdatingComment, Ot as listUpdatingCommunities, Q as isStringDomain, R as ipnsNameToIpnsOverPubsubTopic, Rr as stringifyPrimitive, Rt as require_sha256, Sr as logger_default, Tr as setErrorMap, Tt as findUpdatingCommunity, a as ChallengeRequestMessageSchema, an as CommunityIpfsSchema, ar as e$1, b as areEquivalentCommunityAddresses, br as PKCError, bt as waitForUpdateInCommunityInstanceWithErrorAndTimeout, ct as removeUndefinedValuesRecursively, dn as PubsubTopicSchema, en as CommunityAnchorSchema, ft as retryKuboIpfsAdd, gt as sleepUntilTimeoutOrAbort, hr as FailedToFetchCommentIpfsFromGatewaysError, ht as shortifyCid, ir as e, k as doesDomainAddressHaveCapitalLetter, kn as CommentUpdateSchema, kt as refreshTrackedCommentAliases, lt as replaceXWithY, mr as require_retry, mt as shortifyAddress, nt as rejectWhenAbortSignalFires, r as ChallengeMessageSchema, rr as t$1, rt as rejectWhenCommunityStopsOrAborts, s as ChallengeVerificationMessageSchema, sr as r, t as ChallengeAnswerMessageSchema, tr as n$1, ut as resolveWhenPredicateIsTrue, vt as throwIfAbortSignalAborted, wt as findUpdatingComment, xn as CommentIpfsSchema, xr as messages, y as version_default, yt as timestamp, z as isAbortError, zt as TimeoutError } from "./schema-AXrL86Q4.js";
3
+ import { $ as applyNameResolvedCacheToCrosspost, At as verifyCommentModeration, B as tryToDeleteCommunitiesThatFailedToBeDeletedBefore, Bn as RpcExportCommunityModLogsParamSchema, Bt as normalizeCreatePublicationAuthor, Cn as parseDecryptedChallengeVerification, Ct as signVote, Dn as parseRpcCommentEventWithPKCErrorIfItFails, Dt as verifyChallengeVerification, E as createKuboRpcClient, En as parsePKCUserOptionsSchemaWithPKCErrorIfItFails, F as listCommunitiesSync, Fn as RpcCidParamSchema, Ft as verifyVote, Gn as RpcFetchCidResultSchema, Gt as normalizeCommunityInputFromCommunity, Hn as RpcExportCommunityParamSchema, Ht as getCommunityAddressFromRecord, I as monitorCommunitiesDirectory, In as RpcCommentRepliesPageParamSchema, It as buildRuntimeAuthor, J as extractCommunityRuntimeFieldsFromParsedPages, Jn as RpcPublishedAnchorRecordResultSchema, Jt as getBufferedPKCAddressFromPublicKey, Kn as RpcPublishAnchorRecordParamSchema, Kt as decode, Ln as RpcCommunityIdentifierParamSchema, Lt as cleanWireAuthor, M as getDefaultDataPath, Mn as RpcAnchorPublishPreparationResultSchema, Mt as verifyCommentUpdate, Nn as RpcAuthorNameParamSchema, On as parseRpcCommentUpdateEventWithPKCErrorIfItFails, Ot as verifyCommentEdit, Pn as RpcCancelExportParamSchema, Pt as verifyCommunityEdit, Q as RepliesPages, Qn as RpcUnsubscribeParamSchema, Rn as RpcCommunityPageParamSchema, Rt as getAuthorNameFromRuntime, Sn as parseDecryptedChallengeAnswerWithPKCErrorIfItFails, St as signCommunityEdit, Tn as parseJsonWithPKCErrorIfFails, Tt as verifyChallengeMessage, Un as RpcExportCommunityResultSchema, Ut as getCommunityNameFromWire, V as CommentClientsManager, Vn as RpcExportCommunityModLogsResultSchema, Vt as buildRuntimeCommunityFields, Wn as RpcFetchCidParamSchema, Wt as getCommunityPublicKeyFromWire, Xn as RpcSubscriptionIdResultSchema, Y as findCommentInPageInstanceRecursively, Yn as RpcResolveAuthorNameResultSchema, Z as parseRawPages, Zn as RpcSuccessResultSchema, Zt as getPKCAddressFromPublicKeySync, _ as createAnchorIpnsRecord$1, _t as signCommentEdit, a as pkcJsChallenges, ar as n$3, at as PKCClientsManager, b as encryptEd25519AesGcm, bn as parseCreateRpcCommunityFunctionArgumentSchemaWithPKCErrorIfItFails, c as RemoteCommunity, cn as parseCommunityAddressWithPKCErrorIfItFails, cr as t$5, d as decodeRpcChallengeAnswerPubsubMsg, dn as parseCommunityEditPubsubMessagePublicationSchemaWithPKCErrorIfItFails, dt as cleanUpBeforePublishing, en as parseCidStringSchemaWithPKCErrorIfItFails, et as cloneCrosspostForRuntime, f as decodeRpcChallengePubsubMsg, fr as nativeFunctions$2, ft as signChallengeAnswer, g as createSigner, gn as parseCreateCommunityEditPublicationOptionsSchemaWithPKCErrorIfItFails, gt as signComment, hn as parseCreateCommentOptionsSchemaWithPKCErrorIfItFails, in as parseCommentIpfsSchemaWithPKCErrorIfItFails, ir as t$3, it as PublicationClientsManager, jn as parseVotePubsubMessagePublicationSchemaWithPKCErrorIfItFails, jt as verifyCommentPubsubMessage, kn as parseSetNewSettingsPKCWsServerSchemaWithPKCErrorIfItFails, kt as verifyCommentIpfs, lt as PKCTypedEmitter, m as decodeRpcChallengeVerificationPubsubMsg, mn as parseCreateCommentModerationOptionsSchemaWithPKCErrorIfItFails, mt as signChallengeRequest, n as RpcRemoteCommunity, o as TrackedInstanceRegistry, on as parseCommentModerationPubsubMessagePublicationSchemaWithPKCErrorIfItFails, ot as InflightFetchManager, p as decodeRpcChallengeRequestPubsubMsg, pn as parseCreateCommentEditOptionsSchemaWithPKCErrorIfItFails, pr as require_undici, qn as RpcPublishChallengeAnswersParamSchema, rn as parseCommentEditPubsubMessagePublicationSchemaWithPKCErrorIfItFails, rt as stripNameResolvedFromCrosspost, s as LRUCache, sn as parseCommentPubsubMessagePublicationWithPKCErrorIfItFails, sr as t$2, t as RpcLocalCommunity, tr as t$4, tt as collectCrosspostAuthorsToResolve, u as KeyvBetterSqlite3, ut as require_lib$1, v as decryptEd25519AesGcm, vt as signCommentModeration, wn as parseDecryptedChallengeWithPKCErrorIfItFails, xn as parseCreateVoteOptionsSchemaWithPKCErrorIfItFails, yn as parseCreateRemoteCommunityFunctionArgumentSchemaWithPKCErrorIfItFails, z as setNativeFunctions$1, zn as RpcEditCommunityParamSchema } from "./rpc-local-community-r51cTBYd.js";
4
+ import { o as getHeliaDebugContext } from "./util-CwzCEPKs.js";
5
5
  import path from "path";
6
6
  import assert from "assert";
7
7
  import fs from "fs";
@@ -612,6 +612,17 @@ var Publication = class extends import_lib.TypedEmitter {
612
612
  if (typeof encryptionPublicKey !== "string") throw Error("Failed to load the encryption public key of community");
613
613
  return getPKCAddressFromPublicKeySync(encryptionPublicKey);
614
614
  }
615
+ _getCommunityFetchAbortSignal() {
616
+ if (!this._communityFetchAbortSignal) {
617
+ this._communityFetchAbortController = new AbortController();
618
+ this._communityFetchAbortSignal = AbortSignal.any([this._communityFetchAbortController.signal, this._pkc._getDestroyAbortSignal()]);
619
+ }
620
+ return this._communityFetchAbortSignal;
621
+ }
622
+ _resetCommunityFetchAbortSignal() {
623
+ this._communityFetchAbortController = void 0;
624
+ this._communityFetchAbortSignal = void 0;
625
+ }
615
626
  _getCommunityCache() {
616
627
  const cached = this._pkc._memCaches.communityForPublishing.get(this.communityAddress, { allowStale: true });
617
628
  if (cached) return cached;
@@ -639,8 +650,12 @@ var Publication = class extends import_lib.TypedEmitter {
639
650
  log("The cache of community is stale, we will use the cached and update in the background");
640
651
  const refresh = this._pkc.getCommunity({
641
652
  publicKey: this.communityPublicKey,
642
- name: this.communityName
643
- }).catch((e) => log.error("Failed to update cache of community", this.communityAddress, e)).finally(() => {
653
+ name: this.communityName,
654
+ abortSignal: this._getCommunityFetchAbortSignal()
655
+ }).catch((e) => {
656
+ if (e?.code === "ERR_GET_COMMUNITY_ABORTED") log("Stopped the background refresh of the community cache", this.communityAddress);
657
+ else log.error("Failed to update cache of community", this.communityAddress, e);
658
+ }).finally(() => {
644
659
  if (this._backgroundCommunityRefresh === refresh) this._backgroundCommunityRefresh = void 0;
645
660
  });
646
661
  this._backgroundCommunityRefresh = refresh;
@@ -649,6 +664,10 @@ var Publication = class extends import_lib.TypedEmitter {
649
664
  } else return this._clientsManager.fetchCommunityForPublishingWithCacheGuard();
650
665
  }
651
666
  async stop() {
667
+ this._communityFetchAbortController?.abort(new PKCError("ERR_GET_COMMUNITY_ABORTED", {
668
+ publicationType: this.getType(),
669
+ communityAddress: this.communityAddress
670
+ }));
652
671
  try {
653
672
  await this._postSucessOrFailurePublishing();
654
673
  } finally {
@@ -985,6 +1004,7 @@ var Publication = class extends import_lib.TypedEmitter {
985
1004
  }
986
1005
  async publish() {
987
1006
  this._validatePublicationFields();
1007
+ if (this._getCommunityFetchAbortSignal().aborted) this._resetCommunityFetchAbortSignal();
988
1008
  this._pkc._publishingPublications.add(this);
989
1009
  try {
990
1010
  return await this._publishAfterRegistering();
@@ -6928,7 +6948,7 @@ var PKC$1 = class extends PKCTypedEmitter {
6928
6948
  this.clients.libp2pJsClients = {};
6929
6949
  if (!this.libp2pJsClientsOptions) return;
6930
6950
  if (!this.httpRoutersOptions) throw Error("httpRoutersOptions is required for libp2pJsClient");
6931
- const { createLibp2pJsClientOrUseExistingOne } = await import("./helia-for-pkc-CQY3-UYD.js");
6951
+ const { createLibp2pJsClientOrUseExistingOne } = await import("./helia-for-pkc-BlDudTLN.js");
6932
6952
  for (const clientOptions of this.libp2pJsClientsOptions) {
6933
6953
  const heliaNode = await createLibp2pJsClientOrUseExistingOne({
6934
6954
  ...clientOptions,
@@ -6987,32 +7007,63 @@ var PKC$1 = class extends PKCTypedEmitter {
6987
7007
  hideClassPrivateProps(this);
6988
7008
  }
6989
7009
  async getCommunity(getCommunityArgs) {
6990
- if (!getCommunityArgs.address && !getCommunityArgs.name && !getCommunityArgs.publicKey) throw new Error("At least one of address, name, or publicKey must be provided");
6991
- const community = await this.createCommunity(getCommunityArgs);
7010
+ const { abortSignal, ...communityIdentifier } = getCommunityArgs;
7011
+ if (!communityIdentifier.address && !communityIdentifier.name && !communityIdentifier.publicKey) throw new Error("At least one of address, name, or publicKey must be provided");
7012
+ if (abortSignal?.aborted) throw new PKCError("ERR_GET_COMMUNITY_ABORTED", {
7013
+ communityIdentifier,
7014
+ abortReason: abortSignal.reason
7015
+ });
7016
+ const community = await this.createCommunity(communityIdentifier, { abortSignal });
6992
7017
  if (typeof community.createdAt === "number") return community;
6993
7018
  const timeoutMs = this._timeouts["community-ipns"];
6994
- await waitForUpdateInCommunityInstanceWithErrorAndTimeout(community, timeoutMs);
7019
+ await waitForUpdateInCommunityInstanceWithErrorAndTimeout({
7020
+ community,
7021
+ timeoutMs,
7022
+ abortSignal
7023
+ });
6995
7024
  return community;
6996
7025
  }
6997
- async getComment(cid) {
7026
+ async getComment(getCommentArgs) {
6998
7027
  logger_default("pkc-js:pkc:getComment");
6999
- const parsedGetCommentArgs = parseRpcCidParam(cid);
7028
+ const { abortSignal, ...cidArgs } = getCommentArgs;
7029
+ const parsedGetCommentArgs = parseRpcCidParam(cidArgs);
7030
+ if (abortSignal?.aborted) throw new PKCError("ERR_GET_COMMENT_ABORTED", {
7031
+ getCommentArgs: parsedGetCommentArgs,
7032
+ abortReason: abortSignal.reason
7033
+ });
7000
7034
  const comment = await this.createComment(parsedGetCommentArgs);
7001
7035
  let lastUpdateError;
7002
7036
  const errorListener = (err) => lastUpdateError = err;
7003
7037
  comment.on("error", errorListener);
7038
+ let abortError;
7039
+ let abortReject;
7040
+ const abortListener = () => {
7041
+ abortError = new PKCError("ERR_GET_COMMENT_ABORTED", {
7042
+ getCommentArgs: parsedGetCommentArgs,
7043
+ abortReason: abortSignal?.reason,
7044
+ lastUpdateError
7045
+ });
7046
+ abortReject?.(abortError);
7047
+ };
7048
+ const abortPromise = new Promise((_, reject) => {
7049
+ abortReject = reject;
7050
+ });
7051
+ abortPromise.catch(() => {});
7052
+ abortSignal?.addEventListener("abort", abortListener);
7004
7053
  const commentTimeout = this._timeouts["comment-ipfs"];
7005
7054
  try {
7006
- await pTimeout(comment._attemptInfintelyToLoadCommentIpfs(), {
7055
+ await pTimeout(Promise.race([comment._attemptInfintelyToLoadCommentIpfs(), abortPromise]), {
7007
7056
  milliseconds: commentTimeout,
7008
7057
  message: lastUpdateError || new TimeoutError(`pkc.getComment({cid: ${parsedGetCommentArgs}}) timed out after ${commentTimeout}ms`)
7009
7058
  });
7010
7059
  if (!comment.signature) throw Error("Failed to load CommentIpfs");
7011
7060
  return comment;
7012
7061
  } catch (e) {
7062
+ if (abortError) throw abortError;
7013
7063
  if (lastUpdateError) throw lastUpdateError;
7014
7064
  throw e;
7015
7065
  } finally {
7066
+ abortSignal?.removeEventListener("abort", abortListener);
7016
7067
  comment.removeListener("error", errorListener);
7017
7068
  await comment.stop();
7018
7069
  }
@@ -7176,7 +7227,7 @@ var PKC$1 = class extends PKCTypedEmitter {
7176
7227
  const log = logger_default("pkc-js:pkc:createLocalCommunity");
7177
7228
  log.trace("Received community options to create a local community instance:", options);
7178
7229
  if (!this._canCreateNewLocalCommunity()) throw new PKCError("ERR_CAN_NOT_CREATE_A_LOCAL_COMMUNITY", { pkcOptions: this._userPKCOptions });
7179
- const { LocalCommunity, createNewLocalCommunityDb, updateInstancePropsWithStartedCommunityOrDb } = await import("./local-community-AZAEiiht.js");
7230
+ const { LocalCommunity, createNewLocalCommunityDb, updateInstancePropsWithStartedCommunityOrDb } = await import("./local-community-4wIeaqty.js");
7180
7231
  const isLocalCommunity = (await listCommunitiesSync(this)).includes(options.address);
7181
7232
  const community = new LocalCommunity(this);
7182
7233
  if (isLocalCommunity) {
@@ -7199,8 +7250,9 @@ var PKC$1 = class extends PKCTypedEmitter {
7199
7250
  if (this.communities.includes(jsonfied.address)) return this._createLocalCommunity(jsonfied);
7200
7251
  else return this._createRemoteCommunityInstance(jsonfied);
7201
7252
  }
7202
- async createCommunity(options = {}) {
7253
+ async createCommunity(options = {}, opts) {
7203
7254
  const log = logger_default("pkc-js:pkc:createCommunity");
7255
+ throwIfAbortSignalAborted(opts?.abortSignal);
7204
7256
  if ("clients" in options) return this._createCommunityInstanceFromJsonifiedCommunity(options);
7205
7257
  const parsedOptions = options;
7206
7258
  log.trace("Received options: ", parsedOptions);
@@ -7532,9 +7584,16 @@ var PKC$1 = class extends PKCTypedEmitter {
7532
7584
  return this._storageLRUs[opts.cacheName];
7533
7585
  }
7534
7586
  _getDestroyAbortSignal() {
7535
- if (!this._destroyAbortController) this._destroyAbortController = new AbortController();
7587
+ if (!this._destroyAbortController) {
7588
+ this._destroyAbortController = new AbortController();
7589
+ if (this.destroyed) this._destroyAbortController.abort(new PKCError("ERR_PKC_IS_DESTROYED"));
7590
+ }
7536
7591
  return this._destroyAbortController.signal;
7537
7592
  }
7593
+ _combineWithDestroyAbortSignal(abortSignal) {
7594
+ const destroySignal = this._getDestroyAbortSignal();
7595
+ return abortSignal ? AbortSignal.any([abortSignal, destroySignal]) : destroySignal;
7596
+ }
7538
7597
  async destroy() {
7539
7598
  const log = logger_default("pkc-js:pkc:destroy");
7540
7599
  if (this.destroyed) return;
@@ -7624,9 +7683,22 @@ var PKCWithRpcClient = class extends PKC$1 {
7624
7683
  await super.destroy();
7625
7684
  await this._pkcRpcClient.destroy();
7626
7685
  }
7627
- async getComment(commentCid) {
7628
- const parsedArgs = parseRpcCidParam(commentCid);
7629
- const commentIpfs = await this._pkcRpcClient.getComment(parsedArgs);
7686
+ async getComment(getCommentArgs) {
7687
+ const { abortSignal, ...cidArgs } = getCommentArgs;
7688
+ const parsedArgs = parseRpcCidParam(cidArgs);
7689
+ const cancellation = rejectWhenAbortSignalFires({
7690
+ abortSignal: this._combineWithDestroyAbortSignal(abortSignal),
7691
+ error: () => new PKCError("ERR_GET_COMMENT_ABORTED", {
7692
+ getCommentArgs: parsedArgs,
7693
+ abortReason: abortSignal?.reason
7694
+ })
7695
+ });
7696
+ let commentIpfs;
7697
+ try {
7698
+ commentIpfs = await Promise.race([this._pkcRpcClient.getComment(parsedArgs), cancellation.promise]);
7699
+ } finally {
7700
+ cancellation.cleanup();
7701
+ }
7630
7702
  return this.createComment({
7631
7703
  ...parsedArgs,
7632
7704
  raw: {
@@ -7639,8 +7711,9 @@ var PKCWithRpcClient = class extends PKC$1 {
7639
7711
  if (!getCommunityArgs.address && !getCommunityArgs.name && !getCommunityArgs.publicKey) throw new Error("At least one of address, name, or publicKey must be provided");
7640
7712
  return super.getCommunity(getCommunityArgs);
7641
7713
  }
7642
- async createCommunity(options = {}) {
7714
+ async createCommunity(options = {}, opts) {
7643
7715
  const log = logger_default("pkc-js:pkc-with-rpc-client:createCommunity");
7716
+ throwIfAbortSignalAborted(opts?.abortSignal);
7644
7717
  const parsedRpcOptions = "clients" in options ? options : parseCreateRpcCommunityFunctionArgumentSchemaWithPKCErrorIfItFails(options);
7645
7718
  log.trace("Received community options to create a community instance over RPC:", options);
7646
7719
  const hasIdentifier = "address" in parsedRpcOptions && typeof parsedRpcOptions.address === "string" || "name" in parsedRpcOptions && typeof parsedRpcOptions.name === "string" || "publicKey" in parsedRpcOptions && typeof parsedRpcOptions.publicKey === "string";
@@ -7663,9 +7736,24 @@ var PKCWithRpcClient = class extends PKC$1 {
7663
7736
  const updatePromise = new Promise((resolve) => community.once("update", resolve));
7664
7737
  let error;
7665
7738
  const errorPromise = new Promise((resolve) => community.once("error", (err) => resolve(error = err)));
7666
- await community._createAndSubscribeToNewUpdatingCommunity(community);
7667
- await community.update();
7668
- await Promise.race([updatePromise, errorPromise]);
7739
+ const cancellation = rejectWhenCommunityStopsOrAborts({
7740
+ community,
7741
+ abortSignal: this._combineWithDestroyAbortSignal(opts?.abortSignal)
7742
+ });
7743
+ try {
7744
+ await Promise.race([community._createAndSubscribeToNewUpdatingCommunity(community), cancellation.promise]);
7745
+ await Promise.race([community.update(), cancellation.promise]);
7746
+ await Promise.race([
7747
+ updatePromise,
7748
+ errorPromise,
7749
+ cancellation.promise
7750
+ ]);
7751
+ } catch (e) {
7752
+ await community.stop().catch((stopErr) => log.error("Failed to stop a cancelled community instance", stopErr));
7753
+ throw e;
7754
+ } finally {
7755
+ cancellation.cleanup();
7756
+ }
7669
7757
  await community.stop();
7670
7758
  if (error) throw error;
7671
7759
  await community._attachExportsSubscription();
@@ -1,5 +1,5 @@
1
1
  import { i as __toESM, n as __exportAll, r as __require, t as __commonJSMin } from "./chunk-2rV9d50f.js";
2
- import { $ as pubsubTopicToDhtKey, $n as n$9, $t as CommunityChallengeSettingSchema, A as extractNetworkErrorDetails, Ar as object, At as trackStartedCommunity, B as isIpfsCid, Cn as CommentUpdateChallengeReservedFieldNames, Ct as findUpdatingCommunity, D as deepMergeRuntimeFields, Dn as CommentUpdateSchema, Dr as custom, E as createAbortError, En as CommentUpdateReservedFields, Er as boolean, Et as listUpdatingCommunities, Fn as CommentEditChallengeRequestToEncryptSchema, Ft as untrackUpdatingCommunity, Gn as ChallengeAnswersSchema, Gt as CommentModerationPubsubMessagePublicationSchema, H as isIpns, Hn as AuthorAddressSchema, Ht as CommunityEditPubsubMessagePublicationSchema, I as getPostUpdateTimestampRange, It as require_sha256$1, Jn as CommunityAddressSchema, Jt as CommentModerationsTableRowSchema, Kn as CidPathSchema, L as hideClassPrivateProps, Ln as CommentEditPubsubMessagePublicationWithFlexibleAuthorSchema, Mn as GetPageParamSchema, Mr as string, Mt as trackUpdatingCommunity, Nn as ModQueuePageIpfsSchema, Nt as untrackStartedCommunity, O as derivePublicationFromChallengeRequest, On as CommentUpdateSignedPropertyNames, Or as literal, Ot as refreshTrackedCommunityAliases, Pn as PageIpfsSchema, Pt as untrackUpdatingComment, Q as isStringDomain, R as ipnsNameToIpnsOverPubsubTopic, Rt as pTimeout, Sn as CommentSignedPropertyNames, Sr as require_ms$1, St as findUpdatingComment, Tn as CommentUpdateForChallengeVerificationSignedPropertyNames, Tr as array, U as isIpnsPath, Un as AuthorCommentIpfsReservedFields, Ut as CreateCommunityEditPublicationOptionsWithRefinementSchema, V as isIpfsPath, Vn as CreateCommentEditOptionsWithRefinementSchema, Vt as CommunityEditPublicationSignedPropertyNames, Wt as CommentModerationChallengeRequestToEncryptSchema, X as isRequestPubsubPublicationOfPost, Xn as CreateSignerSchema, Xt as ChallengeFileFactorySchema, Yn as CommunityAuthorChallengeReservedFieldNames, Yt as CreateCommentModerationOptionsWithRefinementSchema, Z as isRequestPubsubPublicationOfReply, Zn as n$10, Zt as ChallengeFileSchema, _ as PKCUserOptionBaseSchema, _n as CommentChallengeRequestToEncryptSchema, _r as FailedToFetchPageIpfsFromGatewaysError, _t as timestamp, an as CreateNewLocalCommunityUserOptionsSchema, ar as r$8, b as areEquivalentCommunityAddresses, br as logger_default, c as ChallengeVerificationMessageSignedPropertyNames, cn as ExportCommunityModLogsOptionsSchema, cr as r$7, ct as resolveWhenPredicateIsTrue, dn as CreateVoteUserOptionsWithRefinementSchema, dr as e$4, en as CommunityEditOptionsSchema, f as DecryptedChallengeSchema, fn as VoteChallengeRequestToEncryptSchema, fr as require_retry$1, ft as shortifyAddress, g as PKCParsedOptionsSchema, gr as FailedToFetchGenericIpfsFromGatewaysError, gt as throwIfAbortSignalAborted, h as NameResolverSerializedSchema, hn as VoteSignedPropertyNames, hr as FailedToFetchCommunityFromGatewaysError, i as ChallengeMessageSignedPropertyNames, in as CommunitySignedPropertyNames, ir as t$11, it as removeNullUndefinedEmptyObjectsValuesRecursively, j as fetchAndValidateIpnsRecordFromGateway, jn as CreateCommentOptionsWithRefinementSchema, jr as record, k as doesDomainAddressHaveCapitalLetter, kr as number, l as DecryptedChallengeAnswerSchema, lr as t$10, m as NameResolveCacheOptionsSchema, mr as FailedToFetchCommentUpdateFromGatewaysError, mt as sleepUntilTimeoutOrAbort, n as ChallengeAnswerMessageSignedPropertyNames, nn as CommunityIpfsReservedFields, nr as e$6, o as ChallengeRequestMessageSignedPropertyNames, on as CreateRemoteCommunityFunctionArgumentSchema, or as t$12, p as DecryptedChallengeVerificationSchema, pn as VotePubsubMessagePublicationSchema, pr as FailedToFetchCommentIpfsFromGatewaysError, pt as shortifyCid, qn as CidStringSchema, qt as CommentModerationSignedPropertyNames, rn as CommunityIpfsSchema, rr as e$5, sn as CreateRpcCommunityFunctionArgumentSchema, sr as n$8, tn as CommunityExportRecordsSchema, tr as t$13, tt as raceAgainstAbort, un as RpcRemoteCommunityUpdateEventResultSchema, ur as t$9, v as PKCUserOptionsSchema, vn as CommentIpfsReservedFields, vr as PKCError, vt as waitForUpdateInCommunityInstanceWithErrorAndTimeout, wr as _enum, wt as listStartedCommunities, x as calculateIpfsCidV0, xn as CommentPubsubMessageWithFlexibleAuthorRefinementSchema, xr as require_supports_color, xt as findStartedCommunity, yn as CommentIpfsSchema, yr as messages, z as isAbortError, zn as CommentEditSignedPropertyNames, zt as CommunityEditPublicationChallengeRequestToEncryptSchema } from "./schema-BUUhufdT.js";
2
+ import { $ as pubsubTopicToDhtKey, $n as n$10, $t as ChallengeFileSchema, A as extractNetworkErrorDetails, An as CommentUpdateSignedPropertyNames, Ar as literal, At as refreshTrackedCommunityAliases, B as isIpfsCid, Bt as pTimeout, Cn as CommentPubsubMessageWithFlexibleAuthorRefinementSchema, Cr as require_supports_color, Ct as findStartedCommunity, D as deepMergeRuntimeFields, Dn as CommentUpdateForChallengeVerificationSignedPropertyNames, Dr as array, E as createAbortError, Er as _enum, Et as listStartedCommunities, Fn as ModQueuePageIpfsSchema, Ft as untrackStartedCommunity, Gn as AuthorCommentIpfsReservedFields, Gt as CreateCommunityEditPublicationOptionsWithRefinementSchema, H as isIpns, I as getPostUpdateTimestampRange, In as PageIpfsSchema, It as untrackUpdatingComment, Jn as CidPathSchema, Kt as CommentModerationChallengeRequestToEncryptSchema, L as hideClassPrivateProps, Ln as CommentEditChallengeRequestToEncryptSchema, Lt as untrackUpdatingCommunity, Mr as object, Mt as trackStartedCommunity, Nn as CreateCommentOptionsWithRefinementSchema, Nr as record, O as derivePublicationFromChallengeRequest, On as CommentUpdateReservedFields, Or as boolean, Ot as listUpdatingCommunities, Pn as GetPageParamSchema, Pr as string, Pt as trackUpdatingCommunity, Q as isStringDomain, Qn as CreateSignerSchema, Qt as ChallengeFileFactorySchema, R as ipnsNameToIpnsOverPubsubTopic, Rt as require_sha256$1, Sr as logger_default, Tn as CommentUpdateChallengeReservedFieldNames, Tt as findUpdatingCommunity, U as isIpnsPath, Un as CreateCommentEditOptionsWithRefinementSchema, Ut as CommunityEditPublicationSignedPropertyNames, V as isIpfsPath, Vn as CommentEditSignedPropertyNames, Vt as CommunityEditPublicationChallengeRequestToEncryptSchema, Wn as AuthorAddressSchema, Wt as CommunityEditPubsubMessagePublicationSchema, X as isRequestPubsubPublicationOfPost, Xn as CommunityAddressSchema, Xt as CommentModerationsTableRowSchema, Yn as CidStringSchema, Yt as CommentModerationSignedPropertyNames, Z as isRequestPubsubPublicationOfReply, Zn as CommunityAuthorChallengeReservedFieldNames, Zt as CreateCommentModerationOptionsWithRefinementSchema, _ as PKCUserOptionBaseSchema, _n as VoteSignedPropertyNames, _r as FailedToFetchCommunityFromGatewaysError, an as CommunityIpfsSchema, ar as e$5, b as areEquivalentCommunityAddresses, bn as CommentIpfsReservedFields, br as PKCError, bt as waitForUpdateInCommunityInstanceWithErrorAndTimeout, c as ChallengeVerificationMessageSignedPropertyNames, cn as CreateRemoteCommunityFunctionArgumentSchema, cr as t$12, dr as t$10, f as DecryptedChallengeSchema, fn as RpcRemoteCommunityUpdateEventResultSchema, fr as t$9, g as PKCParsedOptionsSchema, gr as FailedToFetchCommentUpdateFromGatewaysError, gt as sleepUntilTimeoutOrAbort, h as NameResolverSerializedSchema, hn as VotePubsubMessagePublicationSchema, hr as FailedToFetchCommentIpfsFromGatewaysError, ht as shortifyCid, i as ChallengeMessageSignedPropertyNames, in as CommunityIpfsReservedFields, ir as e$6, j as fetchAndValidateIpnsRecordFromGateway, jr as number, k as doesDomainAddressHaveCapitalLetter, kn as CommentUpdateSchema, kr as custom, l as DecryptedChallengeAnswerSchema, ln as CreateRpcCommunityFunctionArgumentSchema, lr as n$8, m as NameResolveCacheOptionsSchema, mn as VoteChallengeRequestToEncryptSchema, mr as require_retry$1, mt as shortifyAddress, n as ChallengeAnswerMessageSignedPropertyNames, nn as CommunityEditOptionsSchema, o as ChallengeRequestMessageSignedPropertyNames, on as CommunitySignedPropertyNames, or as t$11, ot as removeNullUndefinedEmptyObjectsValuesRecursively, p as DecryptedChallengeVerificationSchema, pn as CreateVoteUserOptionsWithRefinementSchema, pr as e$4, qn as ChallengeAnswersSchema, qt as CommentModerationPubsubMessagePublicationSchema, rn as CommunityExportRecordsSchema, rr as t$13, sn as CreateNewLocalCommunityUserOptionsSchema, sr as r$8, tn as CommunityChallengeSettingSchema, tr as n$9, tt as raceAgainstAbort, un as ExportCommunityModLogsOptionsSchema, ur as r$7, ut as resolveWhenPredicateIsTrue, v as PKCUserOptionsSchema, vr as FailedToFetchGenericIpfsFromGatewaysError, vt as throwIfAbortSignalAborted, wn as CommentSignedPropertyNames, wr as require_ms$1, wt as findUpdatingComment, x as calculateIpfsCidV0, xn as CommentIpfsSchema, xr as messages, yn as CommentChallengeRequestToEncryptSchema, yr as FailedToFetchPageIpfsFromGatewaysError, yt as timestamp, z as isAbortError, zn as CommentEditPubsubMessagePublicationWithFlexibleAuthorSchema } from "./schema-AXrL86Q4.js";
3
3
  import { t as all } from "./src-CYIMjhjK.js";
4
4
  import { createHash } from "node:crypto";
5
5
  import { pathToFileURL } from "node:url";
@@ -99717,7 +99717,7 @@ var PublicationClientsManager = class extends PKCClientsManager {
99717
99717
  const community = directCommunityInstance || await this._pkc.createCommunity({
99718
99718
  name: this._publication.communityName,
99719
99719
  publicKey: this._publication.communityPublicKey
99720
- });
99720
+ }, { abortSignal: this._publication._getCommunityFetchAbortSignal() });
99721
99721
  this._communityForUpdating = {
99722
99722
  community,
99723
99723
  error: this.handleErrorEventFromCommunity.bind(this),
@@ -99806,7 +99806,11 @@ var PublicationClientsManager = class extends PKCClientsManager {
99806
99806
  if (!updatingCommunityInstance.community.raw.communityIpfs) {
99807
99807
  const timeoutMs = this._pkc._timeouts["community-ipns"];
99808
99808
  try {
99809
- await waitForUpdateInCommunityInstanceWithErrorAndTimeout(updatingCommunityInstance.community, timeoutMs);
99809
+ await waitForUpdateInCommunityInstanceWithErrorAndTimeout({
99810
+ community: updatingCommunityInstance.community,
99811
+ timeoutMs,
99812
+ abortSignal: this._publication._getCommunityFetchAbortSignal()
99813
+ });
99810
99814
  communityIpfs = updatingCommunityInstance.community.raw.communityIpfs;
99811
99815
  } catch (e) {
99812
99816
  await this.cleanUpUpdatingCommunityInstance();
@@ -129211,14 +129215,16 @@ var RpcRemoteCommunity = class extends RemoteCommunity {
129211
129215
  const log = logger_default("pkc-js:rpc-remote-community:stop");
129212
129216
  if (this.state === "stopped") return;
129213
129217
  if (this._updatingRpcCommunityInstanceWithListeners) await this._cleanupMirroringUpdatingCommunity();
129214
- else if (this._updateRpcSubscriptionId) {
129215
- try {
129216
- await this._pkc._pkcRpcClient.unsubscribe(this._updateRpcSubscriptionId);
129217
- } catch (e) {
129218
- log.error("Failed to unsubscribe from communityUpdate", e);
129218
+ else {
129219
+ if (this._updateRpcSubscriptionId) {
129220
+ try {
129221
+ await this._pkc._pkcRpcClient.unsubscribe(this._updateRpcSubscriptionId);
129222
+ } catch (e) {
129223
+ log.error("Failed to unsubscribe from communityUpdate", e);
129224
+ }
129225
+ this._updateRpcSubscriptionId = void 0;
129226
+ log.trace(`Stopped the update of remote community (${this.address}) via RPC`);
129219
129227
  }
129220
- this._updateRpcSubscriptionId = void 0;
129221
- log.trace(`Stopped the update of remote community (${this.address}) via RPC`);
129222
129228
  untrackUpdatingCommunity(this._pkc, this);
129223
129229
  }
129224
129230
  this._setRpcClientStateWithEmission("stopped");
@@ -5153,6 +5153,9 @@ var messages;
5153
5153
  messages["ERR_FETCH_OVER_IPNS_OVER_PUBSUB_RETURNED_UNDEFINED"] = "libp2p Fetch over IPNS-Over-Pubsub returned undefined when requested from a peer";
5154
5154
  messages["ERR_FAILED_TO_DIAL_ANY_PEERS_PROVIDING_CID"] = "Failed to dial and connect to any peers providing a CID";
5155
5155
  messages["ERR_GET_COMMUNITY_TIMED_OUT"] = "pkc.getCommunity({address}) timed out";
5156
+ messages["ERR_GET_COMMUNITY_ABORTED"] = "Aborted while waiting for the community record to load";
5157
+ messages["ERR_COMMUNITY_STOPPED_WHILE_LOADING"] = "The community instance was stopped while its record was being loaded";
5158
+ messages["ERR_GET_COMMENT_ABORTED"] = "Aborted while waiting for the comment record to load";
5156
5159
  messages["ERR_TIMEOUT_WAITING_FOR_PUBSUB_TOPIC_PEERS"] = "Timeout waiting for propagation of pubsub topic peers";
5157
5160
  messages["ERR_PUBSUB_TOPIC_PEER_WAIT_ABORTED"] = "Aborted while waiting for a peer to subscribe to a pubsub topic";
5158
5161
  messages["ERR_IPNS_DIRECT_FETCH_ABORTED"] = "Aborted while fetching an IPNS record directly from subscribers/providers";
@@ -6463,7 +6466,8 @@ const additionalCommentReservedFields = [
6463
6466
  "publishingState",
6464
6467
  "updatingState",
6465
6468
  "rowid",
6466
- "nameResolved"
6469
+ "nameResolved",
6470
+ "abortSignal"
6467
6471
  ];
6468
6472
  const CommentPubsubMessageReservedFields = r$2(n([
6469
6473
  ...t$3(CommentIpfsSchema.shape),
@@ -6817,7 +6821,8 @@ const CommunityIpfsReservedFields = r$2([
6817
6821
  "publishingState",
6818
6822
  "updatingState",
6819
6823
  "started",
6820
- "exports"
6824
+ "exports",
6825
+ "abortSignal"
6821
6826
  ], t$3(CommunityIpfsSchema.shape));
6822
6827
  //#endregion
6823
6828
  //#region dist/node/publications/comment-moderation/schema.js
@@ -15613,7 +15618,50 @@ async function resolveWhenPredicateIsTrue(options) {
15613
15618
  listener();
15614
15619
  });
15615
15620
  }
15616
- async function waitForUpdateInCommunityInstanceWithErrorAndTimeout(community, timeoutMs) {
15621
+ function rejectWhenAbortSignalFires(opts) {
15622
+ const { abortSignal, error } = opts;
15623
+ let rejectPromise;
15624
+ const promise = new Promise((_, reject) => {
15625
+ rejectPromise = reject;
15626
+ });
15627
+ promise.catch(() => {});
15628
+ const onAbort = () => rejectPromise?.(error());
15629
+ abortSignal?.addEventListener("abort", onAbort);
15630
+ const cleanup = () => abortSignal?.removeEventListener("abort", onAbort);
15631
+ if (abortSignal?.aborted) onAbort();
15632
+ return {
15633
+ promise,
15634
+ cleanup
15635
+ };
15636
+ }
15637
+ function rejectWhenCommunityStopsOrAborts(opts) {
15638
+ const { community, abortSignal } = opts;
15639
+ let rejectPromise;
15640
+ const promise = new Promise((_, reject) => {
15641
+ rejectPromise = reject;
15642
+ });
15643
+ promise.catch(() => {});
15644
+ const onAbort = () => rejectPromise?.(new PKCError("ERR_GET_COMMUNITY_ABORTED", {
15645
+ communityAddress: community.address,
15646
+ abortReason: abortSignal?.reason
15647
+ }));
15648
+ const onStateChange = (newState) => {
15649
+ if (newState === "stopped") rejectPromise?.(new PKCError("ERR_COMMUNITY_STOPPED_WHILE_LOADING", { communityAddress: community.address }));
15650
+ };
15651
+ community.on("statechange", onStateChange);
15652
+ abortSignal?.addEventListener("abort", onAbort);
15653
+ const cleanup = () => {
15654
+ community.removeListener("statechange", onStateChange);
15655
+ abortSignal?.removeEventListener("abort", onAbort);
15656
+ };
15657
+ if (abortSignal?.aborted) onAbort();
15658
+ return {
15659
+ promise,
15660
+ cleanup
15661
+ };
15662
+ }
15663
+ async function waitForUpdateInCommunityInstanceWithErrorAndTimeout(opts) {
15664
+ const { community, timeoutMs, abortSignal } = opts;
15617
15665
  const wasUpdating = community.state === "updating";
15618
15666
  const updatingStates = [];
15619
15667
  const updatingStateChangeListener = (state) => updatingStates.push(state);
@@ -15642,10 +15690,33 @@ async function waitForUpdateInCommunityInstanceWithErrorAndTimeout(community, ti
15642
15690
  }
15643
15691
  };
15644
15692
  community.on("error", errorListener);
15693
+ let abortError;
15694
+ let abortReject;
15695
+ const abortListener = () => {
15696
+ abortError = new PKCError("ERR_GET_COMMUNITY_ABORTED", {
15697
+ communityAddress: community.address,
15698
+ abortReason: abortSignal?.reason,
15699
+ updatingStates,
15700
+ errors
15701
+ });
15702
+ abortReject?.(abortError);
15703
+ };
15704
+ const abortPromise = new Promise((_, reject) => {
15705
+ abortReject = reject;
15706
+ });
15707
+ abortPromise.catch(() => {});
15708
+ if (abortSignal) if (abortSignal.aborted) abortListener();
15709
+ else abortSignal.addEventListener("abort", abortListener);
15645
15710
  try {
15711
+ if (abortError) throw abortError;
15646
15712
  if (community.state !== "started") await community.update();
15713
+ if (abortError) throw abortError;
15647
15714
  if (criticalError) throw criticalError;
15648
- await pTimeout(Promise.race([updatePromise, nonRetriableErrorPromise]), {
15715
+ await pTimeout(Promise.race([
15716
+ updatePromise,
15717
+ nonRetriableErrorPromise,
15718
+ abortPromise
15719
+ ]), {
15649
15720
  milliseconds: timeoutMs,
15650
15721
  message: criticalError || errors.at(-1) || new PKCError("ERR_GET_COMMUNITY_TIMED_OUT", {
15651
15722
  communityAddress: community.address,
@@ -15657,6 +15728,7 @@ async function waitForUpdateInCommunityInstanceWithErrorAndTimeout(community, ti
15657
15728
  });
15658
15729
  if (criticalError) throw criticalError;
15659
15730
  } catch (e) {
15731
+ if (abortError) throw abortError;
15660
15732
  if (criticalError) throw criticalError;
15661
15733
  if (errors.length > 0) throw errors.at(-1);
15662
15734
  const updatingCommunity = findUpdatingCommunity(community._pkc, {
@@ -15666,6 +15738,7 @@ async function waitForUpdateInCommunityInstanceWithErrorAndTimeout(community, ti
15666
15738
  if (updatingCommunity?._clientsManager._ipnsLoadingOperation?.mainError()) throw updatingCommunity._clientsManager._ipnsLoadingOperation.mainError();
15667
15739
  throw e;
15668
15740
  } finally {
15741
+ abortSignal?.removeEventListener("abort", abortListener);
15669
15742
  if (updateListener) community.removeListener("update", updateListener);
15670
15743
  community.removeListener("error", errorListener);
15671
15744
  community.removeListener("updatingstatechange", updatingStateChangeListener);
@@ -16078,7 +16151,7 @@ function extractNetworkErrorDetails(err, depth = 0) {
16078
16151
  }
16079
16152
  //#endregion
16080
16153
  //#region dist/node/generated-version.js
16081
- const version = "0.0.82";
16154
+ const version = "0.0.84";
16082
16155
  //#endregion
16083
16156
  //#region dist/node/version.js
16084
16157
  const protocolVersion = ProtocolVersionSchema.parse("1.0.0");
@@ -16232,4 +16305,4 @@ const DecryptedChallengeVerificationSchema = object({
16232
16305
  }).strict();
16233
16306
  const ChallengeVerificationMessageSignedPropertyNames = t$3(n$3(ChallengeVerificationMessageSchema.shape, ["signature"]));
16234
16307
  //#endregion
16235
- export { pubsubTopicToDhtKey as $, n$3 as $n, CommunityChallengeSettingSchema as $t, extractNetworkErrorDetails as A, CommentsTableRowSchema as An, object as Ar, trackStartedCommunity as At, isIpfsCid as B, CommentEditsTableRowSchema as Bn, CommunityEditPublicationPubsubReservedFields as Bt, contentContainsMarkdownAudio as C, CommentUpdateChallengeReservedFieldNames as Cn, setErrorMap as Cr, findUpdatingCommunity as Ct, deepMergeRuntimeFields as D, CommentUpdateSchema as Dn, custom as Dr, refreshTrackedCommentAliases as Dt, createAbortError as E, CommentUpdateReservedFields as En, boolean as Er, listUpdatingCommunities as Et, getIpnsRecordInLocalKuboNode as F, CommentEditChallengeRequestToEncryptSchema as Fn, parsedType as Fr, untrackUpdatingCommunity as Ft, isLinkOfAudio as G, ChallengeAnswersSchema as Gn, CommentModerationPubsubMessagePublicationSchema as Gt, isIpns as H, AuthorAddressSchema as Hn, CommunityEditPubsubMessagePublicationSchema as Ht, getPostUpdateTimestampRange as I, CommentEditPubsubMessagePublicationSchema as In, stringifyPrimitive as Ir, require_sha256 as It, isLinkOfVideo as J, CommunityAddressSchema as Jn, CommentModerationsTableRowSchema as Jt, isLinkOfImage as K, CidPathSchema as Kn, CommentModerationReservedFields as Kt, hideClassPrivateProps as L, CommentEditPubsubMessagePublicationWithFlexibleAuthorSchema as Ln, TimeoutError as Lt, genToArray as M, GetPageParamSchema as Mn, string as Mr, trackUpdatingCommunity as Mt, getEquivalentCommunityAddresses as N, ModQueuePageIpfsSchema as Nn, ZodError as Nr, untrackStartedCommunity as Nt, derivePublicationFromChallengeRequest as O, CommentUpdateSignedPropertyNames as On, literal as Or, refreshTrackedCommunityAliases as Ot, getErrorCodeFromMessage as P, PageIpfsSchema as Pn, joinValues as Pr, untrackUpdatingComment as Pt, isStringDomain as Q, t$1 as Qn, CommunityAnchorSchema as Qt, ipnsNameToIpnsOverPubsubTopic as R, CommentEditReservedFields as Rn, pTimeout as Rt, calculateStringSizeSameAsIpfsAddCidV0 as S, CommentSignedPropertyNames as Sn, require_ms as Sr, findUpdatingComment as St, contentContainsMarkdownVideos as T, CommentUpdateForChallengeVerificationSignedPropertyNames as Tn, array as Tr, listUpdatingComments as Tt, isIpnsPath as U, AuthorCommentIpfsReservedFields as Un, CreateCommunityEditPublicationOptionsWithRefinementSchema as Ut, isIpfsPath as V, CreateCommentEditOptionsWithRefinementSchema as Vn, CommunityEditPublicationSignedPropertyNames as Vt, isLinkOfAnimatedImage as W, AuthorReservedFields as Wn, CommentModerationChallengeRequestToEncryptSchema as Wt, isRequestPubsubPublicationOfPost as X, CreateSignerSchema as Xn, ChallengeFileFactorySchema as Xt, isLinkValid as Y, CommunityAuthorChallengeReservedFieldNames as Yn, CreateCommentModerationOptionsWithRefinementSchema as Yt, isRequestPubsubPublicationOfReply as Z, n as Zn, ChallengeFileSchema as Zt, PKCUserOptionBaseSchema as _, CommentChallengeRequestToEncryptSchema as _n, FailedToFetchPageIpfsFromGatewaysError as _r, timestamp as _t, ChallengeRequestMessageSchema as a, CreateNewLocalCommunityUserOptionsSchema as an, r$2 as ar, removeNullUndefinedValues as at, areEquivalentCommunityAddresses as b, CommentPubsubMessageReservedFields as bn, logger_default as br, findCommunityInRegistry as bt, ChallengeVerificationMessageSignedPropertyNames as c, ExportCommunityModLogsOptionsSchema as cn, r$4 as cr, resolveWhenPredicateIsTrue as ct, DecryptedChallengeRequestSchema as d, CreateVoteUserOptionsWithRefinementSchema as dn, e$4 as dr, retryKuboIpfsAddAndProvide as dt, CommunityEditOptionsSchema as en, t$2 as er, pubsubTopicToDhtKeyCid as et, DecryptedChallengeSchema as f, VoteChallengeRequestToEncryptSchema as fn, require_retry as fr, shortifyAddress as ft, PKCParsedOptionsSchema as g, VoteTablesRowSchema as gn, FailedToFetchGenericIpfsFromGatewaysError as gr, throwIfAbortSignalAborted as gt, NameResolverSerializedSchema as h, VoteSignedPropertyNames as hn, FailedToFetchCommunityFromGatewaysError as hr, statMfsPathSafely as ht, ChallengeMessageSignedPropertyNames as i, CommunitySignedPropertyNames as in, t$4 as ir, removeNullUndefinedEmptyObjectsValuesRecursively as it, fetchAndValidateIpnsRecordFromGateway as j, CreateCommentOptionsWithRefinementSchema as jn, record as jr, trackUpdatingComment as jt, doesDomainAddressHaveCapitalLetter as k, CommentUpdateTableRowSchema as kn, number as kr, syncCommunityRegistryEntry as kt, DecryptedChallengeAnswerSchema as l, PubsubTopicSchema as ln, t$7 as lr, retryKuboBlockPutPinAndProvidePubsubTopic as lt, NameResolveCacheOptionsSchema as m, VotePubsubReservedFields as mn, FailedToFetchCommentUpdateFromGatewaysError as mr, sleepUntilTimeoutOrAbort as mt, ChallengeAnswerMessageSignedPropertyNames as n, CommunityIpfsReservedFields as nn, e as nr, removeBlocksFromKuboNode as nt, ChallengeRequestMessageSignedPropertyNames as o, CreateRemoteCommunityFunctionArgumentSchema as on, t$5 as or, removeUndefinedValuesRecursively as ot, DecryptedChallengeVerificationSchema as p, VotePubsubMessagePublicationSchema as pn, FailedToFetchCommentIpfsFromGatewaysError as pr, shortifyCid as pt, isLinkOfMedia as q, CidStringSchema as qn, CommentModerationSignedPropertyNames as qt, ChallengeMessageSchema as r, CommunityIpfsSchema as rn, e$2 as rr, removeMfsFilesSafely as rt, ChallengeVerificationMessageSchema as s, CreateRpcCommunityFunctionArgumentSchema as sn, n$7 as sr, replaceXWithY as st, ChallengeAnswerMessageSchema as t, CommunityExportRecordsSchema as tn, t$3 as tr, raceAgainstAbort as tt, DecryptedChallengeRequestPublicationSchema as u, RpcRemoteCommunityUpdateEventResultSchema as un, t$8 as ur, retryKuboIpfsAdd as ut, PKCUserOptionsSchema as v, CommentIpfsReservedFields as vn, PKCError as vr, waitForUpdateInCommunityInstanceWithErrorAndTimeout as vt, contentContainsMarkdownImages as w, CommentUpdateForChallengeVerificationSchema as wn, _enum as wr, listStartedCommunities as wt, calculateIpfsCidV0 as x, CommentPubsubMessageWithFlexibleAuthorRefinementSchema as xn, require_supports_color as xr, findStartedCommunity as xt, version_default as y, CommentIpfsSchema as yn, messages as yr, writeKuboFilesWithTimeout as yt, isAbortError as z, CommentEditSignedPropertyNames as zn, CommunityEditPublicationChallengeRequestToEncryptSchema as zt };
16308
+ export { pubsubTopicToDhtKey as $, n as $n, ChallengeFileSchema as $t, extractNetworkErrorDetails as A, CommentUpdateSignedPropertyNames as An, literal as Ar, refreshTrackedCommunityAliases as At, isIpfsCid as B, CommentEditReservedFields as Bn, pTimeout as Bt, contentContainsMarkdownAudio as C, CommentPubsubMessageWithFlexibleAuthorRefinementSchema as Cn, require_supports_color as Cr, findStartedCommunity as Ct, deepMergeRuntimeFields as D, CommentUpdateForChallengeVerificationSignedPropertyNames as Dn, array as Dr, listUpdatingComments as Dt, createAbortError as E, CommentUpdateForChallengeVerificationSchema as En, _enum as Er, listStartedCommunities as Et, getIpnsRecordInLocalKuboNode as F, ModQueuePageIpfsSchema as Fn, ZodError as Fr, untrackStartedCommunity as Ft, isLinkOfAudio as G, AuthorCommentIpfsReservedFields as Gn, CreateCommunityEditPublicationOptionsWithRefinementSchema as Gt, isIpns as H, CommentEditsTableRowSchema as Hn, CommunityEditPublicationPubsubReservedFields as Ht, getPostUpdateTimestampRange as I, PageIpfsSchema as In, joinValues as Ir, untrackUpdatingComment as It, isLinkOfVideo as J, CidPathSchema as Jn, CommentModerationReservedFields as Jt, isLinkOfImage as K, AuthorReservedFields as Kn, CommentModerationChallengeRequestToEncryptSchema as Kt, hideClassPrivateProps as L, CommentEditChallengeRequestToEncryptSchema as Ln, parsedType as Lr, untrackUpdatingCommunity as Lt, genToArray as M, CommentsTableRowSchema as Mn, object as Mr, trackStartedCommunity as Mt, getEquivalentCommunityAddresses as N, CreateCommentOptionsWithRefinementSchema as Nn, record as Nr, trackUpdatingComment as Nt, derivePublicationFromChallengeRequest as O, CommentUpdateReservedFields as On, boolean as Or, listUpdatingCommunities as Ot, getErrorCodeFromMessage as P, GetPageParamSchema as Pn, string as Pr, trackUpdatingCommunity as Pt, isStringDomain as Q, CreateSignerSchema as Qn, ChallengeFileFactorySchema as Qt, ipnsNameToIpnsOverPubsubTopic as R, CommentEditPubsubMessagePublicationSchema as Rn, stringifyPrimitive as Rr, require_sha256 as Rt, calculateStringSizeSameAsIpfsAddCidV0 as S, CommentPubsubMessageReservedFields as Sn, logger_default as Sr, findCommunityInRegistry as St, contentContainsMarkdownVideos as T, CommentUpdateChallengeReservedFieldNames as Tn, setErrorMap as Tr, findUpdatingCommunity as Tt, isIpnsPath as U, CreateCommentEditOptionsWithRefinementSchema as Un, CommunityEditPublicationSignedPropertyNames as Ut, isIpfsPath as V, CommentEditSignedPropertyNames as Vn, CommunityEditPublicationChallengeRequestToEncryptSchema as Vt, isLinkOfAnimatedImage as W, AuthorAddressSchema as Wn, CommunityEditPubsubMessagePublicationSchema as Wt, isRequestPubsubPublicationOfPost as X, CommunityAddressSchema as Xn, CommentModerationsTableRowSchema as Xt, isLinkValid as Y, CidStringSchema as Yn, CommentModerationSignedPropertyNames as Yt, isRequestPubsubPublicationOfReply as Z, CommunityAuthorChallengeReservedFieldNames as Zn, CreateCommentModerationOptionsWithRefinementSchema as Zt, PKCUserOptionBaseSchema as _, VoteSignedPropertyNames as _n, FailedToFetchCommunityFromGatewaysError as _r, statMfsPathSafely as _t, ChallengeRequestMessageSchema as a, CommunityIpfsSchema as an, e$2 as ar, removeMfsFilesSafely as at, areEquivalentCommunityAddresses as b, CommentIpfsReservedFields as bn, PKCError as br, waitForUpdateInCommunityInstanceWithErrorAndTimeout as bt, ChallengeVerificationMessageSignedPropertyNames as c, CreateRemoteCommunityFunctionArgumentSchema as cn, t$5 as cr, removeUndefinedValuesRecursively as ct, DecryptedChallengeRequestSchema as d, PubsubTopicSchema as dn, t$7 as dr, retryKuboBlockPutPinAndProvidePubsubTopic as dt, CommunityAnchorSchema as en, t$1 as er, pubsubTopicToDhtKeyCid as et, DecryptedChallengeSchema as f, RpcRemoteCommunityUpdateEventResultSchema as fn, t$8 as fr, retryKuboIpfsAdd as ft, PKCParsedOptionsSchema as g, VotePubsubReservedFields as gn, FailedToFetchCommentUpdateFromGatewaysError as gr, sleepUntilTimeoutOrAbort as gt, NameResolverSerializedSchema as h, VotePubsubMessagePublicationSchema as hn, FailedToFetchCommentIpfsFromGatewaysError as hr, shortifyCid as ht, ChallengeMessageSignedPropertyNames as i, CommunityIpfsReservedFields as in, e as ir, removeBlocksFromKuboNode as it, fetchAndValidateIpnsRecordFromGateway as j, CommentUpdateTableRowSchema as jn, number as jr, syncCommunityRegistryEntry as jt, doesDomainAddressHaveCapitalLetter as k, CommentUpdateSchema as kn, custom as kr, refreshTrackedCommentAliases as kt, DecryptedChallengeAnswerSchema as l, CreateRpcCommunityFunctionArgumentSchema as ln, n$7 as lr, replaceXWithY as lt, NameResolveCacheOptionsSchema as m, VoteChallengeRequestToEncryptSchema as mn, require_retry as mr, shortifyAddress as mt, ChallengeAnswerMessageSignedPropertyNames as n, CommunityEditOptionsSchema as nn, t$2 as nr, rejectWhenAbortSignalFires as nt, ChallengeRequestMessageSignedPropertyNames as o, CommunitySignedPropertyNames as on, t$4 as or, removeNullUndefinedEmptyObjectsValuesRecursively as ot, DecryptedChallengeVerificationSchema as p, CreateVoteUserOptionsWithRefinementSchema as pn, e$4 as pr, retryKuboIpfsAddAndProvide as pt, isLinkOfMedia as q, ChallengeAnswersSchema as qn, CommentModerationPubsubMessagePublicationSchema as qt, ChallengeMessageSchema as r, CommunityExportRecordsSchema as rn, t$3 as rr, rejectWhenCommunityStopsOrAborts as rt, ChallengeVerificationMessageSchema as s, CreateNewLocalCommunityUserOptionsSchema as sn, r$2 as sr, removeNullUndefinedValues as st, ChallengeAnswerMessageSchema as t, CommunityChallengeSettingSchema as tn, n$3 as tr, raceAgainstAbort as tt, DecryptedChallengeRequestPublicationSchema as u, ExportCommunityModLogsOptionsSchema as un, r$4 as ur, resolveWhenPredicateIsTrue as ut, PKCUserOptionsSchema as v, VoteTablesRowSchema as vn, FailedToFetchGenericIpfsFromGatewaysError as vr, throwIfAbortSignalAborted as vt, contentContainsMarkdownImages as w, CommentSignedPropertyNames as wn, require_ms as wr, findUpdatingComment as wt, calculateIpfsCidV0 as x, CommentIpfsSchema as xn, messages as xr, writeKuboFilesWithTimeout as xt, version_default as y, CommentChallengeRequestToEncryptSchema as yn, FailedToFetchPageIpfsFromGatewaysError as yr, timestamp as yt, isAbortError as z, CommentEditPubsubMessagePublicationWithFlexibleAuthorSchema as zn, TimeoutError as zt };
@@ -1,4 +1,4 @@
1
- import { et as pubsubTopicToDhtKeyCid, vr as PKCError } from "./schema-BUUhufdT.js";
1
+ import { br as PKCError, et as pubsubTopicToDhtKeyCid } from "./schema-AXrL86Q4.js";
2
2
  import { ipnsSelector } from "ipns/selector";
3
3
  import { equals } from "uint8arrays/equals";
4
4
  //#region dist/node/helia/util.js
@@ -1,2 +1,2 @@
1
- import { a as getShortCid, i as getShortAddress, n as challenges, o as nativeFunctions, r as createAnchorIpnsRecord, s as setNativeFunctions, t as PKC } from "./chunks/node-B1J8psGZ.js";
1
+ import { a as getShortCid, i as getShortAddress, n as challenges, o as nativeFunctions, r as createAnchorIpnsRecord, s as setNativeFunctions, t as PKC } from "./chunks/node-B7GkmuSc.js";
2
2
  export { challenges, createAnchorIpnsRecord, PKC as default, getShortAddress, getShortCid, nativeFunctions, setNativeFunctions };
@@ -1,7 +1,7 @@
1
- import { $n as n, L as hideClassPrivateProps, br as logger_default, st as replaceXWithY, tr as t, vr as PKCError, xt as findStartedCommunity } from "../../chunks/schema-BUUhufdT.js";
2
- import { _ as parseRpcPublishAnchorRecordParam, c as parseRpcAuthorNameParam, d as parseRpcCommentRepliesPageParam, f as parseRpcCommunityIdentifierParam, g as parseRpcExportCommunityParam, h as parseRpcExportCommunityModLogsParam, l as parseRpcCancelExportParam, m as parseRpcEditCommunityParam, p as parseRpcCommunityPageParam, t as PKC, u as parseRpcCidParam, v as parseRpcPublishChallengeAnswersParam, y as parseRpcUnsubscribeParam } from "../../chunks/node-B1J8psGZ.js";
3
- import { An as parseVoteChallengeRequestToEncryptSchemaWithPKCErrorIfItFails, K as buildPageRuntimeFields, Sn as parseDecryptedChallengeAnswerWithPKCErrorIfItFails, _n as parseCreateNewLocalCommunityUserOptionsSchemaWithPKCErrorIfItFails, an as parseCommentModerationChallengeRequestToEncryptSchemaWithPKCErrorIfItFails, ct as pLimit, kn as parseSetNewSettingsPKCWsServerSchemaWithPKCErrorIfItFails, ln as parseCommunityEditChallengeRequestToEncryptSchemaWithPKCErrorIfItFails, lr as stringify, nn as parseCommentEditChallengeRequestToEncryptSchemaWithPKCErrorIfItFails, nr as t$1, nt as extractCrosspostRuntimeFields, q as buildPagesRuntimeFields, st as pRetry, tn as parseCommentChallengeRequestToEncryptSchemaWithPKCErrorIfItFails, un as parseCommunityEditOptionsSchemaWithPKCErrorIfItFails, ut as require_lib, vn as parseCreatePKCWsServerOptionsSchemaWithPKCErrorIfItFails } from "../../chunks/rpc-local-community-0XmKyOdO.js";
4
- import { t as LocalCommunity } from "../../chunks/local-community-DRm3r1-Y.js";
1
+ import { Ct as findStartedCommunity, L as hideClassPrivateProps, Sr as logger_default, br as PKCError, lt as replaceXWithY, rr as t, tr as n } from "../../chunks/schema-AXrL86Q4.js";
2
+ import { _ as parseRpcPublishAnchorRecordParam, c as parseRpcAuthorNameParam, d as parseRpcCommentRepliesPageParam, f as parseRpcCommunityIdentifierParam, g as parseRpcExportCommunityParam, h as parseRpcExportCommunityModLogsParam, l as parseRpcCancelExportParam, m as parseRpcEditCommunityParam, p as parseRpcCommunityPageParam, t as PKC, u as parseRpcCidParam, v as parseRpcPublishChallengeAnswersParam, y as parseRpcUnsubscribeParam } from "../../chunks/node-B7GkmuSc.js";
3
+ import { An as parseVoteChallengeRequestToEncryptSchemaWithPKCErrorIfItFails, K as buildPageRuntimeFields, Sn as parseDecryptedChallengeAnswerWithPKCErrorIfItFails, _n as parseCreateNewLocalCommunityUserOptionsSchemaWithPKCErrorIfItFails, an as parseCommentModerationChallengeRequestToEncryptSchemaWithPKCErrorIfItFails, ct as pLimit, kn as parseSetNewSettingsPKCWsServerSchemaWithPKCErrorIfItFails, ln as parseCommunityEditChallengeRequestToEncryptSchemaWithPKCErrorIfItFails, lr as stringify, nn as parseCommentEditChallengeRequestToEncryptSchemaWithPKCErrorIfItFails, nr as t$1, nt as extractCrosspostRuntimeFields, q as buildPagesRuntimeFields, st as pRetry, tn as parseCommentChallengeRequestToEncryptSchemaWithPKCErrorIfItFails, un as parseCommunityEditOptionsSchemaWithPKCErrorIfItFails, ut as require_lib, vn as parseCreatePKCWsServerOptionsSchemaWithPKCErrorIfItFails } from "../../chunks/rpc-local-community-r51cTBYd.js";
4
+ import { t as LocalCommunity } from "../../chunks/local-community-5PMI-TDB.js";
5
5
  import { fileURLToPath } from "node:url";
6
6
  import path from "path";
7
7
  import assert from "assert";
@@ -282,15 +282,22 @@ export class RpcRemoteCommunity extends RemoteCommunity {
282
282
  if (this._updatingRpcCommunityInstanceWithListeners) {
283
283
  await this._cleanupMirroringUpdatingCommunity();
284
284
  }
285
- else if (this._updateRpcSubscriptionId) {
286
- try {
287
- await this._pkc._pkcRpcClient.unsubscribe(this._updateRpcSubscriptionId);
288
- }
289
- catch (e) {
290
- log.error("Failed to unsubscribe from communityUpdate", e);
285
+ else {
286
+ if (this._updateRpcSubscriptionId) {
287
+ try {
288
+ await this._pkc._pkcRpcClient.unsubscribe(this._updateRpcSubscriptionId);
289
+ }
290
+ catch (e) {
291
+ log.error("Failed to unsubscribe from communityUpdate", e);
292
+ }
293
+ this._updateRpcSubscriptionId = undefined;
294
+ log.trace(`Stopped the update of remote community (${this.address}) via RPC`);
291
295
  }
292
- this._updateRpcSubscriptionId = undefined;
293
- log.trace(`Stopped the update of remote community (${this.address}) via RPC`);
296
+ // Untracked even without a subscription id. _createAndSubscribeToNewUpdatingCommunity
297
+ // tracks the instance BEFORE _initRpcUpdateSubscription assigns that id, so a subscribe
298
+ // that fails or is cancelled used to leave a stopped instance sitting in
299
+ // _updatingCommunities for findUpdatingCommunity to hand out (issue #277). untrack() is
300
+ // identity-keyed and a no-op for an instance that was never tracked.
294
301
  untrackUpdatingCommunity(this._pkc, this);
295
302
  }
296
303
  this._setRpcClientStateWithEmission("stopped");