fix(storage): ensure bidi-gRPC stream is cleaned up on open failure and close - #18119
Merged
zhixiangli merged 2 commits intoAug 17, 2026
Merged
Conversation
…nd close - Ensure socket_like_rpc is closed if open() or the initial recv() fails or is cancelled in _AsyncReadObjectStream.open() - Add _close_socket_like_rpc helper to safely handle RPC closure - Only call requests_done() in close() if socket_like_rpc is active, and ensure stream state and RPC are closed even if requests_done() fails - Add unit tests for open failures/cancellations and close behavior on inactive or failing streams
Contributor
There was a problem hiding this comment.
Code Review
This pull request introduces robust exception handling and resource cleanup in _AsyncReadObjectStream during stream initialization and closure. Specifically, it wraps the bidi-gRPC stream opening and receiving logic in a try-except block to ensure the stream is closed if an error or cancellation occurs, and updates the close method to safely close the RPC connection even if signaling requests are done fails. Corresponding unit tests have been added to verify these error handling and cleanup paths. Feedback on the changes suggests consolidating the duplicate exception handling blocks for asyncio.CancelledError and Exception in the open method into a single block to reduce redundancy.
…nc_read_object_stream.py Co-authored-by: gemini-code-assist[bot] <176961590+gemini-code-assist[bot]@users.noreply.github.com>
zhixiangli
marked this pull request as ready for review
August 17, 2026 01:21
chandra-siri
approved these changes
Aug 17, 2026
Merged
codyoss
pushed a commit
that referenced
this pull request
Aug 24, 2026
🤖 I have created a release *beep* *boop* --- <details><summary>django-google-spanner: 5.0.1</summary> ## [5.0.1](django-google-spanner-v5.0.0...django-google-spanner-v5.0.1) (2026-08-21) ### Bug Fixes * **django-spanner:** declare django dependency in setup.py ([#18044](#18044)) ([c341469](c341469)) ### Documentation * **django-spanner, common-protos:** centralize CONTRIBUTING.rst pointers ([#18041](#18041)) ([2b056ab](2b056ab)) </details> <details><summary>gapic-generator: 1.39.0</summary> ## [1.39.0](gapic-generator-v1.38.0...gapic-generator-v1.39.0) (2026-08-21) ### Features * **generator:** add fallback compatibility imports for google-api-core helpers ([#17999](#17999)) ([9c13ae2](9c13ae2)) ### Bug Fixes * **generator:** check for api_version header in metadata list ([#18015](#18015)) ([0e63510](0e63510)) * **generator:** move version checks after __all__ in __init__.py temlate ([#18100](#18100)) ([d0efb4d](d0efb4d)) * **generator:** switch core_deps_from_source to DEFAULT_PYTHON_VERSION ([#18050](#18050)) ([895ffa2](895ffa2)) ### Documentation * **handwritten:** centralize CONTRIBUTING.rst pointers ([#17642](#17642)) ([23b9499](23b9499)) </details> <details><summary>gcp-sphinx-docfx-yaml: 3.3.2</summary> ## [3.3.2](gcp-sphinx-docfx-yaml-v3.3.1...gcp-sphinx-docfx-yaml-v3.3.2) (2026-08-21) ### Documentation * **handwritten:** centralize CONTRIBUTING.rst pointers ([#17642](#17642)) ([23b9499](23b9499)) </details> <details><summary>google-ads-admanager: 0.10.2</summary> ## [0.10.2](google-ads-admanager-v0.10.1...google-ads-admanager-v0.10.2) (2026-08-21) ### Features * update googleapis and regenerate ([#18087](#18087)) ([db1622a](db1622a)) </details> <details><summary>google-ads-datamanager: 0.9.2</summary> ## [0.9.2](google-ads-datamanager-v0.9.1...google-ads-datamanager-v0.9.2) (2026-08-21) ### Features * update googleapis and regenerate ([#18087](#18087)) ([db1622a](db1622a)) </details> <details><summary>google-api-core: 2.35.0</summary> ## [2.35.0](google-api-core-v2.34.0...google-api-core-v2.35.0) (2026-08-21) ### Features * **api_core:** add deprecation warning for grpcio < 1.83.0 for PQC ([#18045](#18045)) ([7e2e23e](7e2e23e)) ### Bug Fixes * **api_core:** improve rest path validation ([#17753](#17753)) ([63bfb96](63bfb96)) * **api_core:** support suppress_metrics_header fallback in AuthMetadataPlugin ([#18029](#18029)) ([dd2000d](dd2000d)) ### Documentation * **handwritten:** centralize CONTRIBUTING.rst pointers ([#17642](#17642)) ([23b9499](23b9499)) </details> <details><summary>google-apps-chat: 0.10.5</summary> ## [0.10.5](google-apps-chat-v0.10.4...google-apps-chat-v0.10.5) (2026-08-21) ### Features * update googleapis and regenerate ([#18087](#18087)) ([db1622a](db1622a)) * update sources and regenerate ([#18164](#18164)) ([5ff8274](5ff8274)) </details> <details><summary>google-auth: 2.57.0</summary> ## [2.57.0](google-auth-v2.56.3...google-auth-v2.57.0) (2026-08-21) ### Features * **auth:** add deprecation warning for grpcio < 1.83.0 (PQC support) ([#18070](#18070)) ([68bdaba](68bdaba)) ### Bug Fixes * **auth:** parse hostname for mTLS and PSC endpoint certificate rotat… ([#18153](#18153)) ([b642373](b642373)) * **auth:** prevent TypeError and support home-dir cert fallback for X… ([#18016](#18016)) ([b9a1379](b9a1379)) ### Documentation * **handwritten:** centralize CONTRIBUTING.rst pointers ([#17642](#17642)) ([23b9499](23b9499)) </details> <details><summary>google-auth-httplib2: 0.4.2</summary> ## [0.4.2](google-auth-httplib2-v0.4.1...google-auth-httplib2-v0.4.2) (2026-08-21) ### Documentation * **handwritten:** centralize CONTRIBUTING.rst pointers ([#17642](#17642)) ([23b9499](23b9499)) </details> <details><summary>google-auth-oauthlib: 1.4.1</summary> ## [1.4.1](google-auth-oauthlib-v1.4.0...google-auth-oauthlib-v1.4.1) (2026-08-21) ### Bug Fixes * **google-auth-oauthlib:** prevent port re-use on windows ([#18166](#18166)) ([e20796a](e20796a)) ### Documentation * **handwritten:** centralize CONTRIBUTING.rst pointers ([#17642](#17642)) ([23b9499](23b9499)) </details> <details><summary>google-cloud-alloydb: 0.11.1</summary> ## [0.11.1](google-cloud-alloydb-v0.11.0...google-cloud-alloydb-v0.11.1) (2026-08-21) ### Features * update sources and regenerate ([#18164](#18164)) ([5ff8274](5ff8274)) </details> <details><summary>google-cloud-audit-log: 0.6.2</summary> ## [0.6.2](google-cloud-audit-log-v0.6.1...google-cloud-audit-log-v0.6.2) (2026-08-21) ### Bug Fixes * `google-cloud-audit-log` wheel installs unintended top-level `docs` package ([#17271](#17271)) ([ad99ed1](ad99ed1)) </details> <details><summary>google-cloud-auditmanager: 0.3.1</summary> ## [0.3.1](google-cloud-auditmanager-v0.3.0...google-cloud-auditmanager-v0.3.1) (2026-08-21) ### Features * update googleapis and regenerate ([#18087](#18087)) ([db1622a](db1622a)) * update sources and regenerate ([#18164](#18164)) ([5ff8274](5ff8274)) </details> <details><summary>google-cloud-automl: 2.20.1</summary> ## [2.20.1](google-cloud-automl-v2.20.0...google-cloud-automl-v2.20.1) (2026-08-21) ### Bug Fixes * **automl:** remove unused libcst extra and constraints ([#18056](#18056)) ([9ba4449](9ba4449)) </details> <details><summary>google-cloud-bigquery: 3.44.0</summary> ## [3.44.0](google-cloud-bigquery-v3.43.0...google-cloud-bigquery-v3.44.0) (2026-08-21) ### Features * add PendingDeprecationWarning for to_dataframe and to_arrow conversion methods ([#18021](#18021)) ([6bebf30](6bebf30)) * **bigquery:** add PendingDeprecationWarning for from_dataframe methods ([#18048](#18048)) ([b84b754](b84b754)) * **bigquery:** support queryResultsFormat and compressionCodec in query_and_wait ([#18027](#18027)) ([d172408](d172408)) * check python and dependency versions in bigquery and ndb ([#18075](#18075)) ([62ff6f3](62ff6f3)) ### Documentation * **handwritten:** centralize CONTRIBUTING.rst pointers ([#17642](#17642)) ([23b9499](23b9499)) </details> <details><summary>google-cloud-bigquery-reservation: 1.26.0</summary> ## [1.26.0](google-cloud-bigquery-reservation-v1.25.0...google-cloud-bigquery-reservation-v1.26.0) (2026-08-21) ### Features * update googleapis and regenerate ([#18087](#18087)) ([db1622a](db1622a)) </details> <details><summary>google-cloud-bigquery-storage: 2.41.0</summary> ## [2.41.0](google-cloud-bigquery-storage-v2.40.0...google-cloud-bigquery-storage-v2.41.0) (2026-08-21) ### Features * add pandas-gbq to optional extras ([#18020](#18020)) ([fe91d93](fe91d93)) * **bigquery-storage:** add deprecation warning for to_dataframe ([#18022](#18022)) ([57e7822](57e7822)) * update sources and regenerate ([#18164](#18164)) ([5ff8274](5ff8274)) ### Bug Fixes * **storage:** support updated GapicCallable metadata in tests ([#18031](#18031)) ([24fe2e3](24fe2e3)) ### Documentation * **handwritten:** centralize CONTRIBUTING.rst pointers ([#17642](#17642)) ([23b9499](23b9499)) </details> <details><summary>google-cloud-bigtable: 2.43.0</summary> ## [2.43.0](google-cloud-bigtable-v2.42.0...google-cloud-bigtable-v2.43.0) (2026-08-21) ### Features * update sources and regenerate ([#18164](#18164)) ([5ff8274](5ff8274)) ### Documentation * **handwritten:** centralize CONTRIBUTING.rst pointers ([#17642](#17642)) ([23b9499](23b9499)) </details> <details><summary>google-cloud-build: 3.39.0</summary> ## [3.39.0](google-cloud-build-v3.38.1...google-cloud-build-v3.39.0) (2026-08-21) ### Features * update sources and regenerate ([#18164](#18164)) ([5ff8274](5ff8274)) </details> <details><summary>google-cloud-commerceproducer: 0.1.2</summary> ## [0.1.2](google-cloud-commerceproducer-v0.1.1...google-cloud-commerceproducer-v0.1.2) (2026-08-21) ### Features * update googleapis and regenerate ([#18087](#18087)) ([db1622a](db1622a)) </details> <details><summary>google-cloud-compute: 1.51.0</summary> ## [1.51.0](google-cloud-compute-v1.50.0...google-cloud-compute-v1.51.0) (2026-08-21) ### Features * update googleapis and regenerate ([#18087](#18087)) ([db1622a](db1622a)) </details> <details><summary>google-cloud-compute-v1beta: 0.12.2</summary> ## [0.12.2](google-cloud-compute-v1beta-v0.12.1...google-cloud-compute-v1beta-v0.12.2) (2026-08-21) ### Features * update googleapis and regenerate ([#18087](#18087)) ([db1622a](db1622a)) </details> <details><summary>google-cloud-core: 2.7.0</summary> ## [2.7.0](google-cloud-core-v2.6.1...google-cloud-core-v2.7.0) (2026-08-21) ### Features * **core:** implement PEP 0810 explicit lazy imports in google-cloud-core ([#18052](#18052)) ([5a7ed02](5a7ed02)) ### Bug Fixes * use lowercase x-goog-api-client header ([#18064](#18064)) ([d465d1e](d465d1e)) ### Documentation * **handwritten:** centralize CONTRIBUTING.rst pointers ([#17642](#17642)) ([23b9499](23b9499)) </details> <details><summary>google-cloud-dataform: 0.11.3</summary> ## [0.11.3](google-cloud-dataform-v0.11.2...google-cloud-dataform-v0.11.3) (2026-08-21) ### Features * update googleapis and regenerate ([#18087](#18087)) ([db1622a](db1622a)) * update sources and regenerate ([#18164](#18164)) ([5ff8274](5ff8274)) </details> <details><summary>google-cloud-datastore: 2.26.1</summary> ## [2.26.1](google-cloud-datastore-v2.26.0...google-cloud-datastore-v2.26.1) (2026-08-21) ### Documentation * **handwritten:** centralize CONTRIBUTING.rst pointers ([#17642](#17642)) ([23b9499](23b9499)) </details> <details><summary>google-cloud-dns: 0.37.1</summary> ## [0.37.1](google-cloud-dns-v0.37.0...google-cloud-dns-v0.37.1) (2026-08-21) ### Documentation * **handwritten:** centralize CONTRIBUTING.rst pointers ([#17642](#17642)) ([23b9499](23b9499)) </details> <details><summary>google-cloud-documentai-toolbox: 0.17.3</summary> ## [0.17.3](google-cloud-documentai-toolbox-v0.17.2...google-cloud-documentai-toolbox-v0.17.3) (2026-08-21) ### Bug Fixes * **documentai-toolbox:** contain split_pdf output to output_path ([#18063](#18063)) ([d206212](d206212)) * **documentai-toolbox:** enable autoescape in export_hocr_str ([#18140](#18140)) ([0d671d2](0d671d2)) ### Documentation * **handwritten:** centralize CONTRIBUTING.rst pointers ([#17642](#17642)) ([23b9499](23b9499)) </details> <details><summary>google-cloud-error-reporting: 1.16.1</summary> ## [1.16.1](google-cloud-error-reporting-v1.16.0...google-cloud-error-reporting-v1.16.1) (2026-08-21) ### Documentation * **handwritten:** centralize CONTRIBUTING.rst pointers ([#17642](#17642)) ([23b9499](23b9499)) </details> <details><summary>google-cloud-firestore: 2.29.0</summary> ## [2.29.0](google-cloud-firestore-v2.28.1...google-cloud-firestore-v2.29.0) (2026-08-21) ### Features * update googleapis and regenerate ([#18087](#18087)) ([db1622a](db1622a)) ### Documentation * **handwritten:** centralize CONTRIBUTING.rst pointers ([#17642](#17642)) ([23b9499](23b9499)) </details> <details><summary>google-cloud-iam: 2.25.0</summary> ## [2.25.0](google-cloud-iam-v2.24.1...google-cloud-iam-v2.25.0) (2026-08-21) ### Features * update googleapis and regenerate ([#18087](#18087)) ([db1622a](db1622a)) </details> <details><summary>google-cloud-logging: 3.16.3</summary> ## [3.16.3](google-cloud-logging-v3.16.2...google-cloud-logging-v3.16.3) (2026-08-21) ### Documentation * **handwritten:** centralize CONTRIBUTING.rst pointers ([#17642](#17642)) ([23b9499](23b9499)) </details> <details><summary>google-cloud-monitoring-dashboards: 3.0.0</summary> ## [3.0.0](google-cloud-monitoring-dashboards-v2.22.0...google-cloud-monitoring-dashboards-v3.0.0) (2026-08-21) ### ⚠ BREAKING CHANGES * Remove erroneous google/monitoring/dashboard clients ([#18165](#18165)) ### Bug Fixes * Remove erroneous google/monitoring/dashboard clients ([#18165](#18165)) ([fb0c1b9](fb0c1b9)) </details> <details><summary>google-cloud-ndb: 2.6.0</summary> ## [2.6.0](google-cloud-ndb-v2.5.1...google-cloud-ndb-v2.6.0) (2026-08-21) ### Features * check python and dependency versions in bigquery and ndb ([#18075](#18075)) ([62ff6f3](62ff6f3)) ### Bug Fixes * **ndb:** avoid unbound lock in delete callback ([#17969](#17969)) ([c513b39](c513b39)) * **ndb:** use the single-argument generator.throw() signature ([#18159](#18159)) ([dfb0e36](dfb0e36)) ### Documentation * **handwritten:** centralize CONTRIBUTING.rst pointers ([#17642](#17642)) ([23b9499](23b9499)) </details> <details><summary>google-cloud-oracledatabase: 0.6.2</summary> ## [0.6.2](google-cloud-oracledatabase-v0.6.1...google-cloud-oracledatabase-v0.6.2) (2026-08-21) ### Features * update googleapis and regenerate ([#18087](#18087)) ([db1622a](db1622a)) </details> <details><summary>google-cloud-pubsub: 2.39.2</summary> ## [2.39.2](google-cloud-pubsub-v2.39.1...google-cloud-pubsub-v2.39.2) (2026-08-21) ### Documentation * **handwritten:** centralize CONTRIBUTING.rst pointers ([#17642](#17642)) ([23b9499](23b9499)) </details> <details><summary>google-cloud-recaptcha-enterprise: 1.33.0</summary> ## [1.33.0](google-cloud-recaptcha-enterprise-v1.32.0...google-cloud-recaptcha-enterprise-v1.33.0) (2026-08-21) ### Features * update googleapis and regenerate ([#18087](#18087)) ([db1622a](db1622a)) </details> <details><summary>google-cloud-retail: 2.12.0</summary> ## [2.12.0](google-cloud-retail-v2.11.0...google-cloud-retail-v2.12.0) (2026-08-21) ### Features * update googleapis and regenerate ([#18087](#18087)) ([db1622a](db1622a)) </details> <details><summary>google-cloud-runtimeconfig: 0.37.1</summary> ## [0.37.1](google-cloud-runtimeconfig-v0.37.0...google-cloud-runtimeconfig-v0.37.1) (2026-08-21) ### Documentation * **handwritten:** centralize CONTRIBUTING.rst pointers ([#17642](#17642)) ([23b9499](23b9499)) </details> <details><summary>google-cloud-spanner: 3.70.0</summary> ## [3.70.0](google-cloud-spanner-v3.69.1...google-cloud-spanner-v3.70.0) (2026-08-21) ### Features * check python and dependency versions in spanner packages ([#18177](#18177)) ([b4d9717](b4d9717)) * **spanner:** add DataBoost and auto_partition_mode support to DBAPI driver ([#18161](#18161)) ([5bc3899](5bc3899)) ### Bug Fixes * **spanner:** buffer returned rows in autocommit DML statements ([#18152](#18152)) ([7f8a552](7f8a552)) ### Documentation * **handwritten:** centralize CONTRIBUTING.rst pointers ([#17642](#17642)) ([23b9499](23b9499)) </details> <details><summary>google-cloud-storage: 3.14.0</summary> ## [3.14.0](google-cloud-storage-v3.13.1...google-cloud-storage-v3.14.0) (2026-08-21) ### Features * **storage:** expose metadata parameter in asyncio gRPC calls ([#17634](#17634)) ([aaa263d](aaa263d)) * **storage:** expose object_metadata on AsyncMultiRangeDownloader ([#17411](#17411)) ([a0171ae](a0171ae)) ### Bug Fixes * **storage:** add retry support for finalize and close in AsyncAppendableObjectWriter ([#17733](#17733)) ([92bb6dc](92bb6dc)) * **storage:** ensure bidi-gRPC stream is cleaned up on open failure and close ([#18119](#18119)) ([ac0dfd1](ac0dfd1)) * **storage:** resume bidi reads after idle-stream aborts ([#18061](#18061)) ([3fe1e21](3fe1e21)) * use lowercase x-goog-api-client header ([#18064](#18064)) ([d465d1e](d465d1e)) ### Documentation * correct typos and grammar in README ([#16535](#16535)) ([593a8b0](593a8b0)) * **handwritten:** centralize CONTRIBUTING.rst pointers ([#17642](#17642)) ([23b9499](23b9499)) </details> <details><summary>google-cloud-storage-control: 1.14.0</summary> ## [1.14.0](google-cloud-storage-control-v1.13.0...google-cloud-storage-control-v1.14.0) (2026-08-21) ### Features * update googleapis and regenerate ([#18087](#18087)) ([db1622a](db1622a)) </details> <details><summary>google-cloud-support: 0.5.3</summary> ## [0.5.3](google-cloud-support-v0.5.2...google-cloud-support-v0.5.3) (2026-08-21) ### Features * update sources and regenerate ([#18164](#18164)) ([5ff8274](5ff8274)) </details> <details><summary>google-cloud-testutils: 1.9.3</summary> ## [1.9.3](google-cloud-testutils-v1.9.2...google-cloud-testutils-v1.9.3) (2026-08-21) ### Documentation * **handwritten:** centralize CONTRIBUTING.rst pointers ([#17642](#17642)) ([23b9499](23b9499)) </details> <details><summary>google-cloud-vectorsearch: 0.11.2</summary> ## [0.11.2](google-cloud-vectorsearch-v0.11.1...google-cloud-vectorsearch-v0.11.2) (2026-08-21) ### Features * update googleapis and regenerate ([#18087](#18087)) ([db1622a](db1622a)) </details> <details><summary>google-devicesandservices-health: 0.1.2</summary> ## [0.1.2](google-devicesandservices-health-v0.1.1...google-devicesandservices-health-v0.1.2) (2026-08-21) ### Features * update sources and regenerate ([#18164](#18164)) ([5ff8274](5ff8274)) </details> <details><summary>google-resumable-media: 2.10.2</summary> ## [2.10.2](google-resumable-media-v2.10.1...google-resumable-media-v2.10.2) (2026-08-21) ### Documentation * **handwritten:** centralize CONTRIBUTING.rst pointers ([#17642](#17642)) ([23b9499](23b9499)) </details> <details><summary>googleapis-common-protos: 1.75.2</summary> ## [1.75.2](googleapis-common-protos-v1.75.1...googleapis-common-protos-v1.75.2) (2026-08-21) ### Documentation * **django-spanner, common-protos:** centralize CONTRIBUTING.rst pointers ([#18041](#18041)) ([2b056ab](2b056ab)) </details> <details><summary>pandas-gbq: 0.35.2</summary> ## [0.35.2](pandas-gbq-v0.35.1...pandas-gbq-v0.35.2) (2026-08-21) ### Bug Fixes * **pandas-gbq:** reject backticks in parse_table_id ([#18156](#18156)) ([f687060](f687060)) </details> <details><summary>proto-plus: 1.28.4</summary> ## [1.28.4](proto-plus-v1.28.3...proto-plus-v1.28.4) (2026-08-21) ### Documentation * **handwritten:** centralize CONTRIBUTING.rst pointers ([#17642](#17642)) ([23b9499](23b9499)) </details> <details><summary>sqlalchemy-spanner: 1.20.0</summary> ## [1.20.0](sqlalchemy-spanner-v1.19.0...sqlalchemy-spanner-v1.20.0) (2026-08-21) ### Features * **sqlalchemy-spanner:** export MAX_SIZE constant ([#17922](#17922)) ([e15c21d](e15c21d)) * **sqlalchemy-spanner:** native UUID data type support in dialect ([#17913](#17913)) ([6431932](6431932)) ### Bug Fixes * bump sqlparse from 0.5.5 to 0.6.0 in /packages/sqlalchemy-spanner ([#18136](#18136)) ([3ba7d02](3ba7d02)) * **sqlalchemy-spanner:** fix get_multi_indexes crash on SEARCH indexes ([#17907](#17907)) ([5b2da81](5b2da81)) * **sqlalchemy-spanner:** register TOKENLIST in _type_map for reflection ([#17911](#17911)) ([788208b](788208b)) </details> --- This PR was generated with [Release Please](https://github.com/googleapis/release-please). See [documentation](https://github.com/googleapis/release-please#release-please). --------- Co-authored-by: release-please[bot] <55107282+release-please[bot]@users.noreply.github.com>
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.
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:
Fixes b/547471318 🦕