Skip to content

fix(nui): delete JetStream consumer even when it’s push-based#94

Open
mimmeslemehrzad wants to merge 1 commit intonats-nui:mainfrom
mimmeslemehrzad:fix/js-delete-consumer-handle-push
Open

fix(nui): delete JetStream consumer even when it’s push-based#94
mimmeslemehrzad wants to merge 1 commit intonats-nui:mainfrom
mimmeslemehrzad:fix/js-delete-consumer-handle-push

Conversation

@mimmeslemehrzad
Copy link
Copy Markdown

Summary

Deleting consumers failed for push-based consumers because we fetched them via
stream.Consumer(...) (pull-only). This change falls back to
stream.PushConsumer(...) when ErrNotPullConsumer is returned, then proceeds
to delete the consumer.

Motivation

Users can create JetStream consumers as either pull or push. Deletion should
work regardless of the delivery type.

Technical Notes

  • Try stream.Consumer(ctx, name); on ErrNotPullConsumer, call
    stream.PushConsumer(ctx, name).
  • Keep existing HTTP responses (422 for client issues, 500 for server failures,
    204 on success).
  • No API surface change.

Testing

  • Create a pull consumer, then call DELETE: expect 204.
  • Create a push consumer (with DeliverSubject), then call DELETE: expect 204.
  • Try deleting a non-existent consumer: expect 422 with error payload.
  • Fault-inject JS error: expect 500.

Risks

Low; only affects delete path and narrows error cases.

Checklist

  • Code compiles
  • Linted
  • Manual tests against local NATS/JetStream

When deleting a consumer we previously fetched it via `stream.Consumer(...)`
which only works for pull consumers. If the consumer was push-based, the code
returned `ErrNotPullConsumer`. This change handles that by falling back to
`stream.PushConsumer(...)` when `ErrNotPullConsumer` is encountered, then
proceeds with deletion.

Also improves error handling and keeps HTTP semantics unchanged (204 on success,
422 on client errors, 500 on server errors).

Refs: NATS JetStream `ErrNotPullConsumer`
@pricelessrabbit pricelessrabbit self-assigned this Oct 13, 2025
@mimmeslemehrzad
Copy link
Copy Markdown
Author

any update?

@pricelessrabbit
Copy link
Copy Markdown
Collaborator

Hi and sorry for delay. is this issue occuring only on delete action for push consumers?

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.

2 participants