cloudflare / cloudflare/workers-rs
[Feature] Support reading queue message attempts field
- Dominant language
- Rust
- Stars
- 3.7k
- Forks
- 429
- Avg merge
- 20h 28m
- Merged PRs (30d)
- 7
Description
## Feature Request Form
Thanks for submitting a feature request! Please fill out this form as completely as possible.
### Is there an existing issue for this?
- [x] I have searched the existing issues
### Description
The Rust workers SDK should expose the `attempts` field for queue messages, which is already available in the JavaScript SDK (workers-js).
Currently, when consuming messages from a queue via the `MessageExt` trait, only the following fields are accessible:
- `id()` - Unique message identifier
- `timestamp()` - Message send time
- `body()` - Message payload
**Missing:** `attempts()` method to retrieve the number of delivery attempts for a message
### Why This Is Needed
The `attempts` field indicates how many times a message has been attempted for delivery. This is valuable for:
- Implementing custom retry logic based on attempt count
- Monitoring message delivery reliability
- Logging and debugging failed message deliveries
- Making decisions about message handling based on retry history
- Implementing dead-letter queue patterns
### Implementation Details
- The `attempts` field should be exposed through the `MessageExt` trait with a method like `attempts() -> u32`
- The field is available at the Cloudflare Workers runtime level
- Should be retrievable via the wasm-bindgen bindings in `worker-sys`, similar to how `id()` and `timestamp()` are currently implemented
- Pattern to follow: See `MessageExt` trait in `worker/src/queue.rs` (lines 190-205)
### Related References
- JavaScript SDK (workers-js) - already supports reading the `attempts` field
- Current `MessageExt` implementation: `worker/src/queue.rs`
Contributor guide
Research direction
Start with the MessageExt trait in worker/src/queue.rs around lines 190-205, then inspect the related worker-sys wasm-bindgen bindings used by id() and timestamp(). Expose the queue message attempts value through an attempts() method returning u32, and confirm the Rust SDK builds with the new API available to consumers.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- rust, wasm
- Domain
- backend
- Issue type
- Feature
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Activity status
- Active
- Clarity
- Clearly specified
- Newbie friendliness
- 84/100