Conversation
Align defaultUserAgent with the gRPC over HTTP/2 User-Agent specification (grpc-<lang>/<version>): - Emit 'grpc-dart/<packageVersion> (dart/<sdkVersion>)' on dart:io and 'grpc-dart/<packageVersion>' on web. - Keep ChannelOptions() const-constructible while resolving defaultUserAgent dynamically when userAgent is omitted. - Add test/version_test.dart to ensure packageVersion stays synchronized with pubspec.yaml.
PR HealthChangelog Entry ✔️
Changes to files need to be accounted for in their respective changelogs. This check can be disabled by tagging the PR with Breaking changes ✔️
This check can be disabled by tagging the PR with API leaks ✔️The following packages contain symbols visible in the public API, but not exported by the library. Export these symbols or remove them from your publicly visible API.
This check can be disabled by tagging the PR with |
Package publishingIf you have publishing permissions, you can use the links below to publish the changes after merging this PR.
Documentation at https://github.com/dart-lang/ecosystem/wiki/Publishing-automation. |
mosuem
reviewed
Sep 18, 2026
mosuem
left a comment
Contributor
There was a problem hiding this comment.
[AI-agent] Overall LGTM! A few minor comments inline.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Updates
defaultUserAgentinpackage:grpcfrom the hardcodeddart-grpc/2.0.0string (originally set in 2019) to the standard gRPC over HTTP/2 specification format (grpc-dart/<package_version> (dart/<sdk_version>)ondart:ioandgrpc-dart/<package_version>on web), and updatesX-User-AgentinXhrClientConnection(xhr_transport.dart) from'grpc-web-dart/0.1'to'grpc-web-dart/<package_version>'.Background & Motivation
dart-grpcvsgrpc-dart): The gRPC over HTTP/2 protocol specification defines theUser-Agentgrammar as:grpc-go/<ver>,grpc-java/<ver>,grpc-python/<ver>,grpc-node/<ver>,grpc-c++/<ver>) emitsgrpc-<lang>/<ver>. Becausepackage:grpcemitteddart-grpc/2.0.0, Google Cloud / OnePlatform telemetry extractors matching\bgrpc-<lang>/([0-9A-Za-z.-]+)failed to recognize Dart gRPC requests as a gRPC client library (unknown-grpc-client) or extract the version.2.0.0):defaultUserAgentwas frozen at2.0.0across all2.x–5.xreleases, making it impossible to distinguishpackage:grpcversions or Dart SDK runtime versions (dart/<sdk_version>) in backend diagnostics.Changes
lib/src/version.dart(const packageVersion = '5.2.0';) verified againstpubspec.yamlintest/version_test.dart.user_agent_io.dartifdart.library.js_interopuser_agent_web.dart) sodefaultUserAgentincludes(dart/<sdk_version>)ondart:ioandgrpc-dart/5.2.0on web.XhrClientConnection(lib/src/client/transport/xhr_transport.dart) to sendX-User-Agent: grpc-web-dart/$packageVersion.ChannelOptions({String? userAgent})to remainconstwhile resolvinguserAgent ?? defaultUserAgent.test/version_test.dart) and browser (test/version_web_test.dart) unit tests.