Skip to content

MQ-1267 Change queues oldestMessageTimestamp to use kj::Date#6445

Open
KennethRuan wants to merge 2 commits intocloudflare:mainfrom
KennethRuan:kruan/enhance-queues-oldest-message-timestamp-type
Open

MQ-1267 Change queues oldestMessageTimestamp to use kj::Date#6445
KennethRuan wants to merge 2 commits intocloudflare:mainfrom
KennethRuan:kruan/enhance-queues-oldest-message-timestamp-type

Conversation

@KennethRuan
Copy link
Copy Markdown
Contributor

Summary

In previous PRs, new metrics were added to the Queues API surface.

#6246
#6354
#6339

As pointed out in #6246, it would be clearer to return a JS Date for oldestMessageTimestamp. This PR implements that change so that oldestMessageTimestamp in the three APIs modified above, all return Date | undefined instead of number.

Changes

This PR includes changes to queue.c++ and queue.h features that are gated behind an experimental flag, as such they are non-breaking. We also make a correction to the metrics() method to use JSG_REQUIRE_NONNULL (see here).

Sentinel Value
We wanted to surface oldestMessageTimestamp as Date | undefined to the user. However, since Date(0) (JS Date at the UNIX epoch) and undefined appear the same over the wire, we opt to treat the zero value as a sentinel and manually set it to kj::none so that it appears as undefined to the end user.

An additional test was also added to ensure that the sentinel value is handled properly.

Testing

  • bazel test //src/workerd/api/tests:queue-metrics-sentinel-test@
  • bazel test //src/workerd/api/tests:queue-metrics-sentinel-test@all-compat-flags

@KennethRuan KennethRuan requested review from a team as code owners March 27, 2026 19:10
@KennethRuan KennethRuan force-pushed the kruan/enhance-queues-oldest-message-timestamp-type branch from 7c6cb80 to d73a4e7 Compare March 27, 2026 20:46
@KennethRuan KennethRuan force-pushed the kruan/enhance-queues-oldest-message-timestamp-type branch from d73a4e7 to 1b54323 Compare March 27, 2026 21:14
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.

1 participant