Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Pull timeout error doesn't have a code for easy error handling. #412

Closed
Sh33pman opened this issue Dec 13, 2018 · 5 comments
Closed

Pull timeout error doesn't have a code for easy error handling. #412

Sh33pman opened this issue Dec 13, 2018 · 5 comments
Assignees
Labels
api: pubsub Issues related to the googleapis/nodejs-pubsub API. type: question Request for information or clarification. Not an issue.

Comments

@Sh33pman
Copy link

Sh33pman commented Dec 13, 2018

Environment details

  • OS: Mac OSX
  • Node.js version: v8.12.0
  • npm version: v6.4.1
  • @google-cloud/pubsub version: v0.22.0

Steps to reproduce

  1. Using pull function on pubsub.v1.SubscriberClient to pull messages from the a subscription, the example code works for testing, here is a bit of code I used to print the message:
subscriptionClient.pull().catch((err) => {
  let error_json = {};

  Object.getOwnPropertyNames(err).forEach(function (key) {
    error_json[key] = err[key];
  });
  console.log(err);
  console.log(error_json);
});
  1. Ensure there is no messages sent to the subscription.
  2. Wait until it reaches the pull timeout, will take 10 minutes.

Printed error

Error: Retry total timeout exceeded before any response was received
    at repeat (/Users/sh33pman/workspace/staffshift-bumblebee/node_modules/google-gax/build/src/api_callable.js:190:26)
    at Timeout.setTimeout [as _onTimeout] (/Users/sh33pman/workspace/staffshift-bumblebee/node_modules/google-gax/build/src/api_callable.js:218:25)
    at ontimeout (timers.js:498:11)
    at tryOnTimeout (timers.js:323:5)
    at Timer.listOnTimeout (timers.js:290:5)
{
	stack: 'Error: Retry total timeout exceeded before any response was received\n    at repeat (/Users/sh33pman/workspace/staffshift-bumblebee/node_modules/google-gax/build/src/api_callable.js:190:26)\n    at Timeout.setTimeout [as _onTimeout] (/Users/sh33pman/workspace/staffshift-bumblebee/node_modules/google-gax/build/src/api_callable.js:218:25)\n    at ontimeout (timers.js:498:11)\n    at tryOnTimeout (timers.js:323:5)\n    at Timer.listOnTimeout (timers.js:290:5)',
	message: 'Retry total timeout exceeded before any response was received'
}

The issue I'm currently facing is I need to handle that error so because it a new pull call needs to be started to ensure we keep checking for messages.

@JustinBeckwith JustinBeckwith added triage me I really want to be triaged. 🚨 This issue needs some love. labels Dec 14, 2018
@callmehiphop callmehiphop added type: question Request for information or clarification. Not an issue. and removed triage me I really want to be triaged. 🚨 This issue needs some love. labels Dec 18, 2018
@callmehiphop
Copy link
Contributor

You could try increasing the timeout for the request

const minute = 60000;
subscriptionClient.pull(null, {timeout: minute * 20});

Otherwise you could use the returnImmediately option. It should be noted that setting this option will cause the backend to respond immediately even if there are no messages available, so you'll have to implement your own polling logic.

subscriptionClient.pull({returnImmediately: true});

@Sh33pman
Copy link
Author

Sh33pman commented Jan 7, 2019

@callmehiphop Sure but the issue with setting the timeout to 20 minutes, during times that the system is not busy the you will still have the same failure, also I personally think having an error code on the error makes more sense so you can identify why the pull failed.

In version 0.9.0 when pull was still on const PubSub = require('@google-cloud/pubsub'); object it didn't actually return an error if it timed out but rather returned an object with no messages, so would it not make sense to do the same or add an error code to the error so you could handle the timeout error in the same manner.

@callmehiphop
Copy link
Contributor

My mistake! I didn't realize that google-gax was not supplying an error code of any kind. A status code would indeed be helpful here. I'm going to open an issue on google-gax and hopefully we can get this whole thing sorted out soon.

@Sh33pman
Copy link
Author

Sh33pman commented Jan 7, 2019

@callmehiphop Thanks 😄

@callmehiphop
Copy link
Contributor

Closing per #423, should be fixed in the next release!

@google-cloud-label-sync google-cloud-label-sync bot added the api: pubsub Issues related to the googleapis/nodejs-pubsub API. label Jan 31, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
api: pubsub Issues related to the googleapis/nodejs-pubsub API. type: question Request for information or clarification. Not an issue.
Projects
None yet
Development

No branches or pull requests

3 participants