Skip to content

Conversation

@dholms
Copy link
Collaborator

@dholms dholms commented Oct 21, 2025

Client lib for bluesky-social/indigo#1170

⚠️ Similarly WIP - name very likely to change

This is mostly meant to get a sense for how the tool feels to use

Comment on lines 48 to 49
this.bufferedAcks.push(id)
resolve(true)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think there's a case to be made that this should resolve only once the buffered ack is processed. I don't think it would be a very big change if we prefer that.

@dholms dholms mentioned this pull request Nov 14, 2025
handler: NexusHandler,
wsOpts: NexusWebsocketOptions = {},
) {
this.abortController = new AbortController()
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nit: You could init this at the declaration to make things less verbose:

private readonly abortController = new AbortController()

await response.arrayBuffer()

if (!response.ok) {
await response.arrayBuffer()
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Body was already consumed above

Suggested change
await response.arrayBuffer()

},
body: JSON.stringify({ dids }),
})
await response.arrayBuffer()
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nit: A more resource efficient way to drain would avoid putting it memory (though in practice it doesn't probably matter)

    await response.body?.cancel()

https://developer.mozilla.org/en-US/docs/Web/API/ReadableStream/cancel

Cancel is used when you've completely finished with the stream and don't need any more data from it, even if there are chunks enqueued waiting to be read.

Comment on lines +126 to +127
await this.handler.onEvent(evt, { signal: this.abortController.signal })
await this.ackEvent(evt.id)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Would it make sense for the event handler to actually perform the ack ?

Suggested change
await this.handler.onEvent(evt, { signal: this.abortController.signal })
await this.ackEvent(evt.id)
await this.handler.onEvent(evt, {
signal: this.abortController.signal,
ack: async () => this.ackEvent(evt.id)
})

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants