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

fix: Ensure that each request can only fail once. #28

Merged
merged 5 commits into from
May 22, 2024

Conversation

kinyoklion
Copy link
Member

@kinyoklion kinyoklion commented May 21, 2024

On WSL with no network, or running docker without a network, the 'error' and 'timeout' callbacks would both be called. The timeout should only happen after the specified timeout, 5 minutes in the node SDK, but happens immediately under either of those conditions.

This change ensures that each request can only fail one time.

@kinyoklion
Copy link
Member Author

I think there may be another bug where you call close while a reconnect is already scheduled, but I will handle that in another PR.

@kinyoklion kinyoklion marked this pull request as ready for review May 21, 2024 22:13
@kinyoklion kinyoklion requested a review from a team May 21, 2024 22:13
'ms, assuming connection is dead' })
// Timeout doesn't mean that the request is cancelled, just that it has elapsed the timeout.
destroyRequest()
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Being more careful about destroying requests will help to ensure applications are not held open by the event source.


module.exports = g;
var g;

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this just formatting or was there a change?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This file is auto-generated based on the other files. I am not sure the cause of the diff here. It looks like most of the formatting is even the same.

* Wrap a callback to ensure it can only be called once.
*/
function once(cb) {
let called = false

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It sure is nice to be single threaded

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It is very nice indeed. (at least the illusion of a single thread.)

@@ -12056,4 +12080,4 @@ module.exports = function isBuffer(arg) {
}

/***/ })
/******/ ]);
/******/ ]);

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

newline

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not sure if it was manually edited before, but it generated this way.

if(!called) {
called = true
cb(...params)
}
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is there a logger util in this library? It's helpful to see logs when something is ignored.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There is not.

@kinyoklion kinyoklion merged commit bcceb35 into main May 22, 2024
2 checks passed
@kinyoklion kinyoklion deleted the rlamb/request-fail-only-once branch May 22, 2024 19:49
kinyoklion pushed a commit that referenced this pull request May 22, 2024
🤖 I have created a release *beep* *boop*
---


##
[2.0.3](v2.0.2...2.0.3)
(2024-05-22)


### Bug Fixes

* Ensure that each request can only fail once.
([#28](#28))
([bcceb35](bcceb35))
* Stop reconnect timer when event source is closed.
([#29](#29))
([a73a118](a73a118))

---
This PR was generated with [Release
Please](https://github.com/googleapis/release-please). See
[documentation](https://github.com/googleapis/release-please#release-please).

Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants