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 2 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: 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 @@ describe("Bot", () => {
const wallet = Wallet.createRandom()
keys = await Client.getKeys(wallet, {
env: "dev",
apiClientFactory: GrpcApiClient.fromOptions,
apiClientFactory: GrpcApiClient.fromOptions as any,
rygine marked this conversation as resolved.
Show resolved Hide resolved
})
})

Expand Down Expand Up @@ -61,7 +61,7 @@ describe("Bot", () => {
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,
})
const convo = await bot.client.conversations.newConversation(
otherClient.address,
Expand All @@ -82,7 +82,7 @@ describe("Bot", () => {
})
const bot = await Bot.create(config, dataSource)
const otherClient = await Client.create(Wallet.createRandom(), {
apiClientFactory: GrpcApiClient.fromOptions,
apiClientFactory: GrpcApiClient.fromOptions as any,
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 @@ export default class Bot {
privateKeyOverride: xmtpKeys,
basePersistence,
disablePersistenceEncryption: true,
apiClientFactory: GrpcApiClient.fromOptions,
apiClientFactory: GrpcApiClient.fromOptions as any,
...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.2",
"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
Loading
Loading