Skip to content

[watermill-nats] wrongly assuming nats ackwait timeout begins when handler function is called #609

@Guillembonet

Description

@Guillembonet

Steps to reproduce

See reproduction steps of issue in underlying library in the following issue: nats-io/nats.go#1929 (comment)

Expected behavior

Context should cancel when message ackwait expires, which is not always the case now.

Actual behavior

Context cancels after ackwait timeout is reached from when message is handled, but ackwait does not begin when message handling begins, but when message is pulled from nats by the internal library (due to pre-buffering).

Possible solution

Either take messages one by one using the PullMaxMessages option, or implement a more sophisticated approach using Fetch instead of Consume. I have some code for this that can serve as inspiration. I can share if anyone is interested.

Maybe the current approach is already fine and ackWait is used only as a limit of time rather than being directly related to when the message is considered expired by nats. In that case, maybe ackWait is not the right value to use there and a configurable timeout should exist which defaults to something more resonable like 10 seconds.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions