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

dont use async #26

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open

dont use async #26

wants to merge 1 commit into from

Conversation

jonathanmorley
Copy link

No description provided.

@@ -39,7 +39,7 @@ describe('DatadogTransport#log(info, callback)', () => {
}
]
.forEach(testCase => {
it(testCase.case, async () => {
it(testCase.case, callback => {
Copy link
Owner

Choose a reason for hiding this comment

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

Why though?

Copy link
Author

Choose a reason for hiding this comment

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

See winstonjs/winston#1532. Winston transports do not support async log functions

This appears to work fine as-is for the most part, but in corner cases where the program may be terminated soon after trying to send a log, you are not currently able to rely on winston's documented feature of a 'finish' event being emitted (I suspect because the callback is immediately executed).

Copy link
Author

Choose a reason for hiding this comment

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

This specific line is a jest feature to allow the jest test execution to wait until the callback is executed (or timeout and fail the test). It appears to be the recommended way to test callback based functions, and this was also required to be able to test the new function (without async/await)

},
body: JSON.stringify(logs)
}).then(() => {
this.emit('logged', info)
Copy link
Author

Choose a reason for hiding this comment

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

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