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

Emit a reconnectFailure event #81

Merged
merged 2 commits into from
Jul 29, 2022
Merged

Conversation

ggrossetie
Copy link
Contributor

err can be undefined on fail event when retryBackoff.backoff is called without an error object:

TypeError: Cannot read properties of undefined (reading 'message')
    at Backoff.<anonymous> (/path/to/project/node_modules/pino-socket/lib/TcpConnection.js:221:100)
    at Backoff.emit (node:events:520:28)
    at Backoff.backoff (/path/to/project/node_modules/backoff/lib/backoff.js:42:14)
    at reconnect (/path/to/project/node_modules/pino-socket/lib/TcpConnection.js:134:18)
    at Socket.closeListener (/path/to/project/node_modules/pino-socket/lib/TcpConnection.js:147:7)
    at Socket.emit (node:events:520:28)
    at TCP.<anonymous> (node:net:687:12)

lib/TcpConnection.js Outdated Show resolved Hide resolved
When the maximum number of backoffs is reached. Error can be undefined.
@ggrossetie ggrossetie changed the title err can be undefined on fail event Emit a reconnectFailure event Jul 29, 2022
@@ -144,7 +144,7 @@ module.exports = function factory (userOptions) {
}
}
if (options.reconnect) {
reconnect()
reconnect(hadError && socketError)
Copy link
Contributor Author

@ggrossetie ggrossetie Jul 29, 2022

Choose a reason for hiding this comment

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

@mcollina I'm thinking about it because it's a breaking change, do you think we should reconnect if the socket was closed (or ended) without an error?

Copy link
Member

Choose a reason for hiding this comment

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

no we shouldn't reconnect.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

done!
I've also added a test to make sure that a close event is sent on the stream when the socket is gracefully closed using socket.destroy() (without an error)

Copy link
Member

@mcollina mcollina left a comment

Choose a reason for hiding this comment

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

lgtm

@mcollina mcollina merged commit 53250e6 into pinojs:master Jul 29, 2022
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.

2 participants