google-gax: native server-streaming cancellation can dispatch another RPC or throw before setup
Les mainteneurs répondent en général sous 1 jour
Personne n'a encore pris cette issue.
Évaluation
- Difficulté
- 4/5
- Temps estimé
- 3-5 jours
- Accessibilité débutants
- 57/100
- Type d'issue
- Bug
- Clarté
- Plutôt claire
- Activité
- Active
- Stack technique
- grpc, node.js, typescript
- Domaine
- backend, networking, testing
Piste de recherche
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.
Rédigé par le modèle d'indexation à partir du texte de l'issue.
Description
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?
- Langage dominant
- TypeScript
- Étoiles
- 3.2k
- Forks
- 732
- Merge moyen
- 2 j 11 h
- PR mergées (30 j)
- 99
Préparer son environnement
- Aucun Dockerfile ni fichier Docker Compose
- Propose un modèle de pull request
- Lire le guide de contribution
Par où commencer
- Lisez l'issue en entier, puis le guide de contribution du projet.
- Signalez en commentaire que vous la prenez — cela évite que deux personnes fassent le même travail.
- Forkez le dépôt et travaillez sur une branche.
- Ouvrez une pull request qui référence le numéro de l'issue.
Autres issues de googleapis/google-cloud-node
-
Broken deprecation chainOuverte
Difficulté 2/5 1-3 heures Accessibilité débutants 66/100
googleapis/google-cloud-node#9854 ·
Les mainteneurs répondent en général sous 1 jour
-
pubsub: "Operation attempted on ended Span" when a modack is flushed after the message was ackedOuverteapi: pubsub
Difficulté 2/5 1-3 heures Accessibilité débutants 82/100
googleapis/google-cloud-node#9853 ·
Les mainteneurs répondent en général sous 1 jour
-
storage: V4 getSignedUrl sorts canonical headers with localeCompare, so they disagree with X-Goog-SignedHeadersPeut-être pris @itsrayeedscodespace l’a pris il y a 9 jours. Ouverteapi: storage
Difficulté 2/5 1-3 heures Accessibilité débutants 82/100
googleapis/google-cloud-node#9840 · 1 commentaire ·
Les mainteneurs répondent en général sous 1 jour
-
firestore: getPartitions() emits gax AutopaginateTrueWarning in every processPeut-être pris @TheRealDanii l’a pris il y a 13 jours. Ouverteapi: firestore
Difficulté 2/5 1-3 heures Accessibilité débutants 76/100
googleapis/google-cloud-node#9736 ·
Les mainteneurs répondent en général sous 1 jour
-
Difficulté 1/5 Moins d'une heure Accessibilité débutants 82/100
googleapis/google-cloud-node#9723 ·
Les mainteneurs répondent en général sous 1 jour
Toutes les issues de googleapis/google-cloud-node
Issues similaires
-
Type/Improvement
Difficulté 2/5 1-3 heures Accessibilité débutants 67/100
OpenNSW/nsw-srilanka#1259 ·
Les mainteneurs répondent en général sous 1 jour
-
Difficulté 2/5 1-3 heures Accessibilité débutants 78/100
oxc-project/tsrs#1010 ·
Les mainteneurs répondent en général sous 1 jour
-
Difficulté 2/5 1-3 heures Accessibilité débutants 78/100
Fission-AI/OpenSpec#2260 ·
Les mainteneurs répondent en général sous 1 jour
-
Add: ESP 1 UKOuvertecheck:passed streams:add
Difficulté 1/5 1-3 heures Accessibilité débutants 64/100
Les mainteneurs répondent en général sous 1 jour
-
area:infra area:storage bug
Difficulté 2/5 1-3 heures Accessibilité débutants 76/100
THU-MAIC/OpenMAIC#2311 · 1 commentaire ·
Les mainteneurs répondent en général sous 1 jour