-
Notifications
You must be signed in to change notification settings - Fork 227
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
Resolve subscription.close() once streams have been flushed. #50
Comments
@STeveShary thanks for reporting! I'm sorry you're running into this issue. Generally we do not return promises directly in any of our methods. Instead we use a decorator to wrap them. I attempted to reproduce the error you were seeing, however in my local testing |
@callmehiphop Thanks for responding. My commit from above: STeveShary@2bf9c33 has a really simple test as part of it. I found that I had to add the code fix to get the test to pass. |
I threw a PR over to help with that. |
@STeveShary we stub the decorators in our unit tests, so promises will not work there unless we return the promise directly, which I think we want to avoid so we can stay uniform with the rest of the code. |
I created the following e2e test in /system-test/pubsub.js it.only('should return a promise', function() {
var subscription = topic.subscription(generateSubName(), {
maxConnections: 1,
});
subscription
.on('error', err => console.error(err))
.on('message', message => {});
return subscription.close().then(function() {
console.log('it works!');
});
}); And it passes/logs as expected. By any chance have you been exclusively testing in the unit test files? That would have the potential for a false positive. |
Hmmm... I know we ran into this problem initially when we were trying to close and make sure the queue was flushed before exiting. Let me look... |
Ok. Jogged the memory. The issue that we ran into is that we found that our acks were not being sent back. This we found was because there is no command that will return a promise that tells us when the queue for acks has been drained. We did see in the
This would be GREAT! But, alas it does not return that promise and therefore we can't know when the queue is clear other than For our tests, we want to send acks for all subscriptions but our tests almost everytime exit before the acks are flushed from the queue. Making |
Ah, I see. In most cases that queue isn't actually used. Its primary function is to act as a backup in case we're unable to make a streaming connection. I'd need to investigate a bit more, but it might be possible to implement a |
@callmehiphop do we need these changes: #52? |
No, it can be closed.
…On Feb 10, 2018 7:59 AM, "Stephen" ***@***.***> wrote:
@callmehiphop <https://github.com/callmehiphop> do we need these changes:
#52 <#52>?
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
<#50 (comment)>,
or mute the thread
<https://github.com/notifications/unsubscribe-auth/ABoNAxVqMbBIlgXK-lvizYdwim4tSqQQks5tTZK4gaJpZM4Rtg2I>
.
|
@STeveShary we've got a fix prepared for this (#92) if you have the bandwidth to test it out that would be fantastic! Otherwise we should have it released within the next day or two. |
* Fixed the failing unit test. * Removed the unreliable assertion
After using the pub/sub client for test, I have found that I wanted to know when the queue was flushed before exiting. The comment in the code states that a promise is returned when no callback is provided: https://github.com/googleapis/nodejs-pubsub/blob/master/src/subscription.js#L377 but the code does not return a promise.
Environment details
Steps to reproduce
.then()
on the promise from the subscription close method.Expected: the callback in the
.then()
is executed.Actual: Error calling .then on undefined.
I have completed a fix with a test here: STeveShary@2bf9c33 . Your contribution guide doesn't recommend a PR yet, but I can create one quickly.
The text was updated successfully, but these errors were encountered: