Change connection error type to warning #225
Open
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
While debugging issue with project on which I'm currently working on I have noticed one issue which ends up in node.js running out of memory situation.
My case is pretty simple, there are some situations, when elastic search instance is not reachable and winston-elasticsearch fails to connect to it. To not loose the errors, which occurs in the mean time you can use buffering feature. Which basically collects errors in array and tries to send when to elastic search when connection again becomes stable. This is great, because it does not let you to loose any stack traces.
Winston itself offers functionality to handleExceptions and handleRejections on the node process its currently running on. These options can be configured per transport level. So we end up in situation, if you use winston-elasticsearch as a transport with handleExceptions and handleRejections set to true if connection to elastic search instance will faill it will push those errors to buffer, because if connection fails it executes
thiz.transport.emit('warning', err))
which is caught by winston, because handleExceptions and handleRejections are set to true.This is not the case if you set buffering to false. Because then instead it executes the line 177 in bulk_writer.js
which emits
thiz.transport.emit('warning', e)
not error.Basically to reproduce it. You need to setup all props as following:
So I'm creating this pull request, to align these too cases and in both buffer endabled and disabled scenarious emit warning instead of error.