google-gax: native server-streaming cancellation can dispatch another RPC or throw before setup
I maintainer di solito rispondono entro 1 giorno
Nessuno ha ancora preso questa issue.
Valutazione
- Difficoltà
- 4/5
- Tempo stimato
- 3-5 giorni
- Idoneità per principianti
- 57/100
- Tipo di issue
- Bug
- Chiarezza
- Abbastanza chiara
- Stato di attività
- Attiva
- Stack tecnologico
- grpc, node.js, typescript
- Ambito
- backend, networking, testing
Direzione di ricerca
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.
Scritto dal modello di indicizzazione a partire dal testo della issue.
Descrizione
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?
- Lingua principale
- TypeScript
- Stelle
- 3.2k
- Fork
- 732
- Merge medio
- 2g 11h
- PR unite (30g)
- 99
Preparare l'ambiente
- Nessun Dockerfile né file Docker Compose
- Ha un modello di pull request
- Leggi la guida per i contributori
Come iniziare
- Leggi tutta la issue e poi la guida ai contributi del progetto.
- Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
- Fai un fork del repository e lavora su un branch.
- Apri una pull request che faccia riferimento al numero della issue.
Altre issue di googleapis/google-cloud-node
-
Broken deprecation chainAperta
Difficoltà 2/5 1-3 ore Idoneità per principianti 66/100
googleapis/google-cloud-node#9854 ·
I maintainer di solito rispondono entro 1 giorno
-
pubsub: "Operation attempted on ended Span" when a modack is flushed after the message was ackedApertaapi: pubsub
Difficoltà 2/5 1-3 ore Idoneità per principianti 82/100
googleapis/google-cloud-node#9853 ·
I maintainer di solito rispondono entro 1 giorno
-
storage: V4 getSignedUrl sorts canonical headers with localeCompare, so they disagree with X-Goog-SignedHeadersForse già presa @itsrayeedscodespace l’ha presa 9 giorni fa. Apertaapi: storage
Difficoltà 2/5 1-3 ore Idoneità per principianti 82/100
googleapis/google-cloud-node#9840 · 1 commento ·
I maintainer di solito rispondono entro 1 giorno
-
firestore: getPartitions() emits gax AutopaginateTrueWarning in every processForse già presa @TheRealDanii l’ha presa 13 giorni fa. Apertaapi: firestore
Difficoltà 2/5 1-3 ore Idoneità per principianti 76/100
googleapis/google-cloud-node#9736 ·
I maintainer di solito rispondono entro 1 giorno
-
Difficoltà 1/5 Meno di un'ora Idoneità per principianti 82/100
googleapis/google-cloud-node#9723 ·
I maintainer di solito rispondono entro 1 giorno
Tutte le issue di googleapis/google-cloud-node
Issue simili
-
Type/Improvement
Difficoltà 2/5 1-3 ore Idoneità per principianti 67/100
OpenNSW/nsw-srilanka#1259 ·
I maintainer di solito rispondono entro 1 giorno
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 78/100
oxc-project/tsrs#1010 ·
I maintainer di solito rispondono entro 1 giorno
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 78/100
Fission-AI/OpenSpec#2260 ·
I maintainer di solito rispondono entro 1 giorno
-
Add: ESP 1 UKApertacheck:passed streams:add
Difficoltà 1/5 1-3 ore Idoneità per principianti 64/100
I maintainer di solito rispondono entro 1 giorno
-
area:infra area:storage bug
Difficoltà 2/5 1-3 ore Idoneità per principianti 76/100
THU-MAIC/OpenMAIC#2311 · 1 commento ·
I maintainer di solito rispondono entro 1 giorno