-
Notifications
You must be signed in to change notification settings - Fork 16
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
Conversation
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. |
'ms, assuming connection is dead' }) | ||
// Timeout doesn't mean that the request is cancelled, just that it has elapsed the timeout. | ||
destroyRequest() |
There was a problem hiding this comment.
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; | ||
|
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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 |
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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) { | |||
} | |||
|
|||
/***/ }) | |||
/******/ ]); | |||
/******/ ]); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
newline
There was a problem hiding this comment.
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) | ||
} |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There is not.
🤖 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>
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.