googleapis / googleapis/google-cloud-node

Stopping retryable function if API call errored

Open
#7,755 2 comments 0 reactions 0 assignees View on GitHub
library: google-cloud-node-core priority: p2 type: bug
Dominant language
TypeScript
Stars
3.2k
Forks
712
Avg merge
2d 3h
Merged PRs (30d)
99

Description

Recently I've been stuck with using [@google-cloud/pubsub](https://www.npmjs.com/package/@google-cloud/pubsub) package because it was returning an error of

**Total timeout of API google.pubsub.v1.Publisher exceeded 60000 milliseconds before any response was received.**

I've browsed a couple of issues and StackOverflow answers already, and it seemed pretty vague and irrelevant to my situation, but thanks to the stack trace, It could give me the entry point to start debugging my issue which is located [here](https://github.com/googleapis/gax-nodejs/blob/main/src/normalCalls/retries.ts#L104) at the retryable function, when I logged the error I could actually get this output

**Error: 14 UNAVAILABLE: Name resolution failed for target DNS:......**

After that, I understood that I'd set the service path wrong and could solve my issue.

The problem that I could notice is with the retryable function, we don't ever catch the error at our callback to make use of and return an error if there is any, and since it's not used, we keep failing and just fallback to the maximum number of retries exceeded.

I was able to get the right error directly by setting this [codeblock](https://github.com/googleapis/gax-nodejs/compare/main...secmohammed:gax-nodejs:fix-stopping-retryable-if-error-returned-from-api-call) right before setting the canceller to null and keep repeating the request.

and now I could get the error that way
**Error: Error: 14 UNAVAILABLE: Name resolution failed for target DNS:....**

The impact now is to return back the right error for the end-users so they can investigate their own issues correctly and stop repeating requests in vain. If that makes sense, I can open a PR with that.

Thanks!

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.