google-gax: native server-streaming cancellation can dispatch another RPC or throw before setup
メンテナーはふだん 1 日以内に返信
まだ誰も着手していません。
評価
- 難易度
- 4/5
- 見積もり時間
- 3〜5日
- 初心者へのやさしさ
- 57/100
- issue の種類
- バグ
- 明瞭さ
- おおむね明確
- 活発さ
- 活発
- 技術スタック
- grpc, node.js, typescript
- 領域
- backend, networking, testing
調査の方向性
Start in core/packages/gax/src/streamingCalls/streaming.ts, especially StreamProxy.cancel(), newStreamingRetryRequest(), and newMakeRequest(); trace how cancellation and retry timers interact. Add regression tests for the four cases listed in the issue, then run the gax package tests covering streaming calls. Done means early cancellation does not start or dereference a request, cancellation stops queued retries and cancels the active attempt, and normal retry and success still work.
索引モデルが issue の本文から書いたものです。
説明
Summary
With native server-streaming retries enabled (gaxStreamingRetries: true), cancellation does not terminate the retry state machine:
- Cancelling during retry backoff still dispatches the next RPC.
- Cancelling before stream setup causes
TypeError: Cannot read properties of undefined (reading 'cancel'). - The active request's
cancelmethod is copied onto the retry wrapper without binding its receiver.
Reproduced on main at c1c70497020b6d0552012a479f538a4b187196ac, macOS arm64, Node 24.22.3. This reproduction uses only local streams and fake timers; no Google Cloud service or credentials are involved.
Reproduction
After installing dependencies and compiling google-gax, run from core/packages/gax:
const {StreamProxy, StreamType} =
require('./build/src/streamingCalls/streaming.js');
const {createDefaultBackoffSettings} = require('./build/src/gax.js');
const sinon = require('sinon');
const {PassThrough} = require('stream');
const retry = {
retryCodes: [14],
backoffSettings: {
...createDefaultBackoffSettings(),
totalTimeoutMillis: undefined,
maxRetries: 3,
initialRetryDelayMillis: 100,
},
};
const clock = sinon.useFakeTimers();
const requests = [];
const proxy = new StreamProxy(
StreamType.SERVER_STREAMING, () => {}, false, true,
);
proxy.on('error', () => {});
proxy.setStream(() => {
const stream = new PassThrough({objectMode: true});
stream.cancel = sinon.spy();
requests.push(stream);
return stream;
}, {}, {}, retry);
requests[0].emit(
'error', Object.assign(new Error('unavailable'), {code: 14}),
);
proxy.cancel();
clock.tick(100);
console.log(requests.length); // Actual: 2; expected: 1.
clock.restore();
const early = new StreamProxy(
StreamType.SERVER_STREAMING, () => {}, false, true,
);
early.cancel();
early.setStream(
() => new PassThrough({objectMode: true}), {}, {}, retry,
); // Throws TypeError reading 'cancel' from undefined.
Cause and proposed scope
StreamProxy.cancel() records _isCancelCalled only when this.stream is absent. Once the retry wrapper exists, cancellation therefore does not block a queued retry. newStreamingRetryRequest() does not retain/clear its retry timer and assigns retryStream.cancel = requestStream.cancel. Conversely, when cancellation happened before setup, the request factory returns undefined and newMakeRequest() immediately dereferences it.
I would like to contribute a narrowly scoped fix that owns cancellation in the native streaming retry state machine: preserve the active transport receiver when cancelling, prevent/clear scheduled retries, and handle cancellation before initialization without starting a request or dereferencing an absent stream. Regression tests would cover early cancellation, cancellation during backoff, cancellation of the current attempt after a retry, and normal retry/success behavior.
I checked the open PR list and cancellation-related PRs. #9359 changes normalCalls/retries.ts (unary calls), so it does not address this streaming path. This report concerns gRPC/native streaming retries, rather than the REST fallback transport issues.
Is this scope acceptable, and is anyone already implementing a fix for this streaming path?
- 主要言語
- TypeScript
- スター
- 3.2k
- フォーク
- 732
- 平均マージ
- 2日 11時間
- マージ済み PR(30日)
- 99
環境構築
- Dockerfile・Docker Compose ファイルなし
- プルリクエストのテンプレートあり
- コントリビューションガイドを読む
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
googleapis/google-cloud-node のほかの issue
-
難易度 2/5 1〜3時間 初心者へのやさしさ 66/100
googleapis/google-cloud-node#9854 ·
メンテナーはふだん 1 日以内に返信
-
pubsub: "Operation attempted on ended Span" when a modack is flushed after the message was ackedオープンapi: pubsub
難易度 2/5 1〜3時間 初心者へのやさしさ 82/100
googleapis/google-cloud-node#9853 ·
メンテナーはふだん 1 日以内に返信
-
storage: V4 getSignedUrl sorts canonical headers with localeCompare, so they disagree with X-Goog-SignedHeaders対応中かも @itsrayeedscodespace が 9 日前に担当しました。 オープンapi: storage
難易度 2/5 1〜3時間 初心者へのやさしさ 82/100
googleapis/google-cloud-node#9840 · コメント 1 件 ·
メンテナーはふだん 1 日以内に返信
-
firestore: getPartitions() emits gax AutopaginateTrueWarning in every process対応中かも @TheRealDanii が 13 日前に担当しました。 オープンapi: firestore
難易度 2/5 1〜3時間 初心者へのやさしさ 76/100
googleapis/google-cloud-node#9736 ·
メンテナーはふだん 1 日以内に返信
-
難易度 1/5 1時間未満 初心者へのやさしさ 82/100
googleapis/google-cloud-node#9723 ·
メンテナーはふだん 1 日以内に返信
googleapis/google-cloud-node の issue をすべて見る
似ている issue
-
Type/Improvement
難易度 2/5 1〜3時間 初心者へのやさしさ 67/100
OpenNSW/nsw-srilanka#1259 ·
メンテナーはふだん 1 日以内に返信
-
難易度 2/5 1〜3時間 初心者へのやさしさ 78/100
oxc-project/tsrs#1010 ·
メンテナーはふだん 1 日以内に返信
-
難易度 2/5 1〜3時間 初心者へのやさしさ 78/100
Fission-AI/OpenSpec#2260 ·
メンテナーはふだん 1 日以内に返信
-
Add: ESP 1 UKオープンcheck:passed streams:add
難易度 1/5 1〜3時間 初心者へのやさしさ 64/100
メンテナーはふだん 1 日以内に返信
-
area:infra area:storage bug
難易度 2/5 1〜3時間 初心者へのやさしさ 76/100
THU-MAIC/OpenMAIC#2311 · コメント 1 件 ·
メンテナーはふだん 1 日以内に返信