Skip to content

fix(datastore): apply the timeout option to every RPC - #36732

Open
ninjapanzer wants to merge 1 commit into
googleapis:mainfrom
ninjapanzer:gitranks/36632-google-cloud-datastore-timeout-option
Open

ninjapanzer wants to merge 1 commit into
googleapis:mainfrom
ninjapanzer:gitranks/36632-google-cloud-datastore-timeout-option

Conversation

@ninjapanzer

@ninjapanzer ninjapanzer commented Nov 17, 2026 •

Copy link
Copy Markdown

Thank you for opening a Pull Request! Before submitting your PR, there are a few things you can do to make sure it goes smoothly:

  • Make sure to open an issue as a bug/issue before writing your code! That way we can discuss the change, evaluate designs, and agree on the general idea.
  • Follow the instructions in CONTRIBUTING. Most importantly, ensure the tests and linter pass by running bundle exec rake ci in the gem subdirectory.
  • Update code documentation if necessary.

The timeout option of Google::Cloud::Datastore.new was set only on the client-wide config. The generated client applies each RPC's own 60 s default first, and Gapic::CallOptions#apply_defaults only fills an empty value, so the option never reached a request.

This copies the timeout to each config.rpcs.*.timeout in Service#service, the same way google-cloud-pubsub does since #14405. Nothing changes when no timeout is given.

A new test/google/cloud/datastore/service_test.rb checks the per-RPC config with and without a timeout, and that lookup, commit and allocate_ids are sent with the configured timeout.

On the unticked CONTRIBUTING box: locally, with Ruby 3.4.8, bundle exec rake test passes only with minitest/mock preloaded (282 runs, 0 failures, 0 errors); without it, existing tests fail with uninitialized constant Minitest::Mock, and rake doctest and rake rubocop (6 offenses in properties.rb) also fail, all identically on main. The changed file has no rubocop offenses. OVERVIEW.md already documents the option as now behaving, so no documentation change was needed.

closes: #36632

Made with GitRanks Contribute and Claude Code (Fable) · Reviewed and submitted by @ninjapanzer

Something off? Tell us or opt out in one step — maintainers are always in control

The timeout given to Google::Cloud::Datastore.new was set only on the
client-wide config. The generated client applies each RPC's own default
(60 s) first, and Gapic::CallOptions#apply_defaults only fills an empty
value, so the option had no effect.

Copy the timeout to each RPC config as well, as google-cloud-pubsub
does since googleapis#14405.
@ninjapanzer
ninjapanzer requested review from a team and yoshi-approver as code owners November 17, 2026 20:57
@google-cla

google-cla Bot commented Nov 17, 2026

Copy link
Copy Markdown

Thanks for your pull request! It looks like this may be your first contribution to a Google open source project. Before we can look at your pull request, you'll need to sign a Contributor License Agreement (CLA).

View this failed invocation of the CLA check for more information.

For the most up to date status, view the checks section at the bottom of the pull request.

@1AbdullahButt 1AbdullahButt left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Correct.

Service#service used to set only config.timeout. Each RPC in the generated V1::Datastore::Client config carries its own 60 s default, and that per-RPC value is applied first, so the top-level value never reached a request. The new override_client_config_timeouts writes the timeout into every config.rpcs.* entry as well. It is the same code as override_client_config_timeouts in google-cloud-pubsub/lib/google/cloud/pubsub/service.rb, so the two libraries now behave the same way.

What I checked:

  • V1::Datastore::Client.new in service.rb is the only place the datastore gem builds a client, so there is no second path that still drops the timeout.
  • With no timeout, the helper is not called, so the per-RPC defaults stay as they were.
  • The new test also checks that the class-level Client.configure keeps its defaults. That matters because the block changes the per-instance config only.

I ran test/google/cloud/datastore/service_test.rb in a ruby:3.3 container (with -rminitest/mock, as the description says): 4 runs, 0 failures. With service.rb reverted to main, 2 of the 4 fail: the per-RPC config test and the "sends requests with the configured timeout" test. So the test catches the bug.

Reviewed with help from Claude Code.

This branch has not been deployed

No deployments
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.

[google-cloud-datastore] timeout option has no effect: per-RPC defaults override it (same as #14050)

2 participants