Deletes don't get broadcasted #1

Closed
opened 2026-04-13 19:13:02 +00:00 by hodlbod · 4 comments
Owner

This is a bug in nostrlib's khatru. It'll require a PR to upstream to add a hook or broadcast them.

This is a bug in nostrlib's khatru. It'll require a PR to upstream to add a hook or broadcast them.

Hi @hodlbod,

Thank you for the explanation.

After tracing the delete flow in both zooid and khatru, I agree that the main issue is at the khatru boundary. Zooid only receives the DeleteEvent(id) callback, which doesn't provide enough context (especially the full kind 5 deletion event) to reliably broadcast the deletion to relays.

I’d like to take ownership of this issue and fix it properly.

Proposed Approach:

  1. Add a new upstream hook in khatruOnDeleteApplied(ctx, deleteEvent, deletedTargetEvent) — that gets called after a target event is successfully deleted.
  2. Once the hook is available, wire it in zooid and use the existing Relay.BroadcastEvent to properly fan out the kind 5 deletion event.

Before I start working on the upstream PR in khatru, could you please confirm:

  • Is this the preferred long-term direction?
  • Are there any other files or existing hooks I should be careful with?
  • Any specific edge cases (like nothing-to-delete, not-author deletes, etc.) that I should preserve or handle carefully?

I'm ready to begin with the khatru patch once you give the go-ahead.

Looking forward to your thoughts.

Hi @hodlbod, Thank you for the explanation. After tracing the delete flow in both zooid and khatru, I agree that the main issue is at the khatru boundary. Zooid only receives the `DeleteEvent(id)` callback, which doesn't provide enough context (especially the full kind 5 deletion event) to reliably broadcast the deletion to relays. I’d like to take ownership of this issue and fix it properly. **Proposed Approach:** 1. Add a new upstream hook in **khatru** — `OnDeleteApplied(ctx, deleteEvent, deletedTargetEvent)` — that gets called after a target event is successfully deleted. 2. Once the hook is available, wire it in zooid and use the existing `Relay.BroadcastEvent` to properly fan out the kind 5 deletion event. Before I start working on the upstream PR in khatru, could you please confirm: - Is this the preferred long-term direction? - Are there any other files or existing hooks I should be careful with? - Any specific edge cases (like nothing-to-delete, not-author deletes, etc.) that I should preserve or handle carefully? I'm ready to begin with the khatru patch once you give the go-ahead. Looking forward to your thoughts.
Author
Owner

I just updated nostrlib from upstream, it looks like fiatjaf may have done some work to fix this. Can you first validate that the issue still exists? If not, we can close this.

I just updated nostrlib from upstream, it looks like fiatjaf may have done some work to fix this. Can you first validate that the issue still exists? If not, we can close this.

Yeah, @hodlbod, it seems like this issue has been resolved.

Yeah, @hodlbod, it seems like this issue has been resolved.
Author
Owner

Awesome, thanks for double checking!

Awesome, thanks for double checking!
Sign in to join this conversation.
No Label
2 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: coracle/zooid#1