You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
generator: generated methods return a promise without .cancel() since request/response logging was added #9790
Run const p = client.asymmetricSign(request) and check typeof p.cancel.
After 200 ms, call p.cancel() if it exists.
Description: client-libraries.md in gax says a method's returned promise can be cancelled with promise.cancel(). Generated clients no longer return that promise. To log the response, each method now returns this.innerApiCalls.X(request, options, wrappedCallback)?.then(...). .then() returns a plain Promise, so the OngoingCallPromise from gax and its cancel() are lost.
Results with the repro (Node 24, REST fallback):
@google-cloud/kms 4.5.0 (gax 4.6.1): typeof p.cancel is function. cancel() closes the connection immediately.
@google-cloud/kms 5.0.0 (gax 5.0.8) and packages/google-cloud-kms on main (0435467, gax 6.14.0): typeof p.cancel is undefined. The request runs until the server answers.
On main, client.innerApiCalls.asymmetricSign(request, {}) still returns a promise with cancel(), and it aborts the fetch.
This came from the logging template change in googleapis/gapic-generator-typescript#1671. The ?.then(...) wrapper is in templates/{cjs,esm}/.../src/$version/$service_client.ts.njk for normal, LRO, diregapic LRO and paged methods.
#9462 added CallOptions.signal, not released yet. With gax main, client.asymmetricSign(request, {signal}) aborts the request because options still reaches gax. So a way to cancel is coming, but the documented one is broken.
Expected: one of:
The returned promise keeps cancel(), for example by copying cancel from the inner promise onto the .then() result and typing the return as gax.CancellablePromise<...>.
client-libraries.md drops promise.cancel() and documents options.signal once gax 6.15.0 is out.
I can send a PR for either.
Why: core/packages/gax/client-libraries.md ("Regular methods") documents promise.cancel(), and it worked before the logging change.
Versions: google-cloud-node main 0435467, @google-cloud/kms 6.3.0, google-gax 6.14.0, Node 24.21.0.
Activity