Skip to content
This repository has been archived by the owner on Jan 16, 2025. It is now read-only.

Call onConnectionLost on all errors #291

Merged
merged 11 commits into from
Oct 31, 2024
Merged
Show file tree
Hide file tree
Changes from 8 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions .changeset/modern-laws-wait.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
---
"@xmtp/grpc-api-client": patch
---

Update to latest `xmtp-js` and call `OnConnectionLost` for all grpc subscribe
errors
6 changes: 3 additions & 3 deletions packages/bot-kit-pro/src/bot.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@
const wallet = Wallet.createRandom()
keys = await Client.getKeys(wallet, {
env: "dev",
apiClientFactory: GrpcApiClient.fromOptions,
apiClientFactory: GrpcApiClient.fromOptions as any,

Check failure on line 36 in packages/bot-kit-pro/src/bot.test.ts

View workflow job for this annotation

GitHub Actions / Lint

Unexpected any. Specify a different type
rygine marked this conversation as resolved.
Show resolved Hide resolved
})
})

Expand Down Expand Up @@ -61,7 +61,7 @@
const config = getConfig()
const bot = await Bot.create(config, dataSource)
const otherClient = await Client.create(Wallet.createRandom(), {
apiClientFactory: GrpcApiClient.fromOptions,
apiClientFactory: GrpcApiClient.fromOptions as any,

Check failure on line 64 in packages/bot-kit-pro/src/bot.test.ts

View workflow job for this annotation

GitHub Actions / Lint

Unexpected any. Specify a different type
})
const convo = await bot.client.conversations.newConversation(
otherClient.address,
Expand All @@ -82,7 +82,7 @@
})
const bot = await Bot.create(config, dataSource)
const otherClient = await Client.create(Wallet.createRandom(), {
apiClientFactory: GrpcApiClient.fromOptions,
apiClientFactory: GrpcApiClient.fromOptions as any,

Check failure on line 85 in packages/bot-kit-pro/src/bot.test.ts

View workflow job for this annotation

GitHub Actions / Lint

Unexpected any. Specify a different type
insipx marked this conversation as resolved.
Show resolved Hide resolved
})
await sleep(100)
const convo = await otherClient.conversations.newConversation(
Expand Down
2 changes: 1 addition & 1 deletion packages/bot-kit-pro/src/bot.ts
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@
privateKeyOverride: xmtpKeys,
basePersistence,
disablePersistenceEncryption: true,
apiClientFactory: GrpcApiClient.fromOptions,
apiClientFactory: GrpcApiClient.fromOptions as any,

Check failure on line 86 in packages/bot-kit-pro/src/bot.ts

View workflow job for this annotation

GitHub Actions / Lint

Unexpected any. Specify a different type
...config.clientOptions,
})
await findOrCreateBot(datasource, config.name)
Expand Down
2 changes: 1 addition & 1 deletion packages/grpc-api-client/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
"@protobuf-ts/runtime": "^2.9.1",
"@protobuf-ts/runtime-rpc": "^2.9.1",
"@xmtp/proto": "^3.61.1",
"@xmtp/xmtp-js": "^11.3.12",
"@xmtp/xmtp-js": "^13.0.3",
"pino": "^8.18.0"
},
"scripts": {
Expand Down
7 changes: 4 additions & 3 deletions packages/grpc-api-client/src/GrpcApiClient.ts
Original file line number Diff line number Diff line change
Expand Up @@ -237,9 +237,10 @@ export default class GrpcApiClient implements ApiClient {

await stream.requests.send(req)
stream.responses.onMessage((msg) => callback(toHttpEnvelope(msg)))
stream.responses.onError((err) =>
this.logger.error({ error: err }, "stream error"),
)
stream.responses.onError((err) => {
this.logger.error({ error: err }, "stream error")
onConnectionLost?.(err)
})
await stream
} catch (e) {
if (isAbortError(e as RpcError)) {
Expand Down
65 changes: 64 additions & 1 deletion yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -3192,6 +3192,24 @@ __metadata:
languageName: node
linkType: hard

"@xmtp/content-type-primitives@npm:^1.0.1":
version: 1.0.2
resolution: "@xmtp/content-type-primitives@npm:1.0.2"
dependencies:
"@xmtp/proto": "npm:^3.61.1"
checksum: 5b54ec02752cf12fc13f1e90ae064608a4e6370932ea13a052c9515d5e8c46186011de62f9b04e0429790ec08ecc7d5913cce85d46e7b60c6bfb2b20db98a8d7
languageName: node
linkType: hard

"@xmtp/content-type-text@npm:^1.0.0":
version: 1.0.0
resolution: "@xmtp/content-type-text@npm:1.0.0"
dependencies:
"@xmtp/content-type-primitives": "npm:^1.0.1"
checksum: b195060ad5686a6ace2772d5208d535d1f5062820629764aec52cedf3f2630885b5913aea6d2f0186a49139845c20d2ded783c6bf998884f09374c07b183141f
languageName: node
linkType: hard

"@xmtp/frames-client@npm:^0.4.3":
version: 0.4.3
resolution: "@xmtp/frames-client@npm:0.4.3"
Expand Down Expand Up @@ -3243,7 +3261,7 @@ __metadata:
"@protobuf-ts/runtime": "npm:^2.9.1"
"@protobuf-ts/runtime-rpc": "npm:^2.9.1"
"@xmtp/proto": "npm:^3.61.1"
"@xmtp/xmtp-js": "npm:^11.3.12"
"@xmtp/xmtp-js": "npm:^13.0.3"
pino: "npm:^8.18.0"
vitest: "npm:^1.0.1"
languageName: unknown
Expand Down Expand Up @@ -3309,6 +3327,18 @@ __metadata:
languageName: node
linkType: hard

"@xmtp/proto@npm:^3.68.0":
version: 3.72.0
resolution: "@xmtp/proto@npm:3.72.0"
dependencies:
long: "npm:^5.2.0"
protobufjs: "npm:^7.0.0"
rxjs: "npm:^7.8.0"
undici: "npm:^5.8.1"
checksum: a60df6fa60a9523978c7ad52696ed393179060ed91fb521dfc2cace3127fcd070527a03c5be99089df6c73aead06c8ce74e86e31b9353cfb2a36986fbb7fc645
languageName: node
linkType: hard

"@xmtp/redis-persistence@workspace:packages/redis-persistence":
version: 0.0.0-use.local
resolution: "@xmtp/redis-persistence@workspace:packages/redis-persistence"
Expand Down Expand Up @@ -3365,6 +3395,24 @@ __metadata:
languageName: node
linkType: hard

"@xmtp/xmtp-js@npm:^13.0.3":
version: 13.0.3
resolution: "@xmtp/xmtp-js@npm:13.0.3"
dependencies:
"@noble/secp256k1": "npm:1.7.1"
"@xmtp/consent-proof-signature": "npm:^0.1.3"
"@xmtp/content-type-primitives": "npm:^1.0.1"
"@xmtp/content-type-text": "npm:^1.0.0"
"@xmtp/proto": "npm:^3.68.0"
"@xmtp/user-preferences-bindings-wasm": "npm:^0.3.6"
async-mutex: "npm:^0.5.0"
elliptic: "npm:^6.5.7"
long: "npm:^5.2.3"
viem: "npm:2.7.15"
checksum: 77f8e5d8de5a9b75b7dabe5e8ff12fb71423857e33d1bf3b6c82e1ad47d5f71b5b7bb8a7f75bde339157b290a7d61225504729a1164a902f6423cc477fa03c76
languageName: node
linkType: hard

"abbrev@npm:^2.0.0":
version: 2.0.0
resolution: "abbrev@npm:2.0.0"
Expand Down Expand Up @@ -4818,6 +4866,21 @@ __metadata:
languageName: node
linkType: hard

"elliptic@npm:^6.5.7":
version: 6.6.0
resolution: "elliptic@npm:6.6.0"
dependencies:
bn.js: "npm:^4.11.9"
brorand: "npm:^1.1.0"
hash.js: "npm:^1.0.0"
hmac-drbg: "npm:^1.0.1"
inherits: "npm:^2.0.4"
minimalistic-assert: "npm:^1.0.1"
minimalistic-crypto-utils: "npm:^1.0.1"
checksum: 27575b0403e010e5d7e7a131fcadce6a7dd1ae82ccb24cc7c20b275d32ab1cb7ecb6a070225795df08407441dc8c7a32efd986596d48d1d6846f64ff8f094af7
languageName: node
linkType: hard

"emittery@npm:^0.13.1":
version: 0.13.1
resolution: "emittery@npm:0.13.1"
Expand Down
Loading