Repository navigation
feat(deps): make chrono optional behind a default feature - #1474
andreinknv wants to merge 2 commits into
Conversation
chrono is marked unmaintained by RUSTSEC-2026-0543. Use jiff for the clock and the RFC 3339 task and annotation timestamps, keeping the exact previous output (`+00:00` offset, 0/3/6/9 fractional digits), and format the request timeout message without chrono (`PT30S`, `P0D`). The new default `chrono` feature keeps `Annotations::for_resource` and `Annotations::with_timestamp` (which take `chrono::DateTime<Utc>`) and schemars' `chrono04` support. With default features disabled, rmcp no longer depends on chrono unless an `auth` feature pulls it in through oauth2.
Codex Review Summary: ✅ CompletedThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
|
@michaelneale is on triage rotation this week and is the reviewer for this one. Labels come from the PR labeler. Please review the change. Automated triage. Labels are a first pass and the assigned maintainer has the final say. |
jokemanfire
left a comment
There was a problem hiding this comment.
Verified at a95b804 from the code and a local A/B run, not the description.
What I ran (Linux, stable 1.96; Windows and MSRV not run here)
- A scratch example (not committed) that formats the same values both ways:
chrono::DateTime::to_rfc3339()vsAnnotations::with_timestamp(..).last_modified, andformat!("request timeout after {}", chrono::Duration::from_std(d).unwrap_or_default())vsServiceError::Timeout{d}.to_string(). - 14 timestamps: seconds 0, pre-epoch (
-1s + 500ms), 2099, and every fractional shape (1ns,1µs,1ms,100ms,123ms,123456µs,123456789ns,999999999ns). - 12 durations: zero, 1ns, 1µs, 1ms, 1.5s, 30s, 5400s, 86400s,
i64::MAXms exactly, one nanosecond past it, andDuration::MAX. - Result: 26/26 identical, including the 0/3/6/9 fractional-digit rule, the
+00:00offset, and the overflow quirk wherechrono::Duration::from_stdfails andunwrap_or_default()printsP0D— yourtoo_longbranch reproduces that exactly. cargo tree -p rmcp -i chrono: default features →chrono v0.4.40(direct, plus throughschemars 1.2.3);--no-default-features --features server,macros→ not in the tree at all. Your opt-out claim holds.
Code read
time::rfc3339is only reachable fromnow_rfc3339, so the sign ofsubsec_nanosecond()for pre-epoch values never reaches it; the digit selection matchesSecondsFormat::AutoSi. The#[cfg(any(client, server))]onIso8601Durationmatches whereServiceError::Timeoutexists.with_timestamp_nowno longer routes throughwith_timestamp, which is what keeps it available without thechronofeature — correct, sincewith_timestampkeeps using chrono's ownto_rfc3339and the two agree (probe above).
Two things worth settling before merge
-
Default users still trip the advisory.
chronois indefault, socargo tree -i chronostill shows it for anyone who does not adddefault-features = false. That is fine as a staged change, but it means the people who filed #1469 (plainrmcp = "3") see no difference incargo deny check advisories, and the opt-out is not documented anywhere a downstream would look. I would like the README and CHANGELOG to carry the exact snippet (default-features = falseplus the feature list they actually need) and one line on the plan to flip the default at the next major. Right now the README change is one line and does not say this. -
The flip is a hard API break, and the migration path is invisible. With the feature off,
Annotations::for_resourceandwith_timestampvanish; at the flip every caller panics at compile time with no replacement that accepts a timestamp. Cheap way to make the eventual break a non-event: add an untypedwith_last_modified_rfc3339(&str)(or ajiff-typed setter) now so non-chrono users have a supported path, and#[deprecated(note = "…")]on the chrono setters in a later release before the default changes. Not required for this PR, but it should be in the PR body as the follow-up plan.
Question: which wasm targets did you verify?
jiff's docs for Timestamp::now() say it "may also panic when SystemTime::now() itself panics. The most common context in which this happens is on the wasm32-unknown-unknown target… you should enable Jiff's js feature". This PR deletes the two target-specific chrono blocks, and CHANGELOG.md:1087 records #234 as "disable wasmbind in chrono for wasm32-unknown-unknown", so that target has been deliberately configured before. I read the old config as panicking the same way (no wasmbind), i.e. parity, but I did not build for wasm32-unknown-unknown to prove it — CI only builds examples/wasi for wasm32-wasip2, which has a real clock. One sentence in the PR body saying "wasm32-unknown-unknown behaves as before / now needs jiff/js" would close it.
None of this blocks the dependency change itself, which I could not fault: the formatting is byte-identical on everything I threw at it and the feature wiring does what it says.
Show the `default-features = false` snippet, what is unavailable without the `chrono` feature, that the `auth` features still pull chrono in through oauth2, and the plan to drop `chrono` from the default features in the next major release.
|
Thanks for checking it so thoroughly. 1. Docs. 9043cdf adds a "Building without chrono" section to the crate README, which is also the crate-level rustdoc. It covers the I left
If you'd rather have it under 2. Migration path. It's now in the PR body as a follow-up plan: a setter that needs no chrono, then deprecating the chrono setters in a later minor, then flipping the default at the next major. I can add the setter in this PR if you'd prefer it now. 3. wasm.
With rmcp's default features, AI assistance: I used an AI coding assistant (Claude Code) to run these checks and draft this reply; I reviewed the results. 🤖 Generated with Claude Code |
Closes #1469.
Discussed in #1469. A downstream test there confirms that chrono drops out of the dependency tree and
cargo deny check advisoriespasses without an ignore.Motivation
chrono is marked unmaintained (RUSTSEC-2026-0543). rmcp depends on it unconditionally, so downstream
cargo deny/cargo auditruns fail on it.Changes
Annotations::with_timestamp_now, and theServiceError::Timeoutmessage now use jiff 1 (default-features = false, features = ["std"]) and a small privatetimemodule. Output is unchanged:+00:00offset, 0/3/6/9 fractional digits, andPT30S/PT1.5S/P0D.chrono. It keepsAnnotations::for_resourceandAnnotations::with_timestamp(which takechrono::DateTime<Utc>) and enablesschemars?/chrono04.default-features = falsesnippet.Compatibility
Nothing changes with default features.
cargo semver-checksreports "no semver update required" for default features and for all features exceptlocal. Withdefault-features = false, rmcp no longer depends on chrono, except throughoauth25 when anauthfeature is enabled.wasm32-unknown-unknownbehaves as before. chrono (as configured since #234) and jiff both read the clock throughstd::time::SystemTime::now(), which panics on that target, and neither pulls injs-sys. A browser build that wants a working clock can enable jiff'sjsfeature; before, the equivalent was chrono'swasmbind.Tests
ServiceError::Timeoutmessage.cargo test --all-features: 1213 passed.cargo test -p rmcp --lib --no-default-features: 208 passed.-D warningswith all features, with all features exceptlocal, and with 8 smaller feature sets, including none. Nightly fmt, nightly docs with--cfg docsrs -Dwarnings, andcargo +1.88.0 check --all-targets --all-featuresall pass.mainand on this branch: a probe that callsAnnotations::with_timestamp_nowtraps onwasm32-unknown-unknownexactly like a directSystemTime::now()call, with no imports in the module; onwasm32-wasip1both print the same timestamp format;examples/wasibuilds forwasm32-wasip2.Follow-up plan
Annotations::with_last_modifiedtaking an RFC 3339 string or ajiff::Timestamp.Annotations::for_resourceandAnnotations::with_timestamp, pointing at that setter.chronofrom the default features.AI assistance: I used an AI coding assistant (Claude Code) to write most of this change and draft this text; I reviewed and tested it.
🤖 Generated with Claude Code