-
Notifications
You must be signed in to change notification settings - Fork 18
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
base: master
Are you sure you want to change the base?
dont use async #26
Conversation
@@ -39,7 +39,7 @@ describe('DatadogTransport#log(info, callback)', () => { | |||
} | |||
] | |||
.forEach(testCase => { | |||
it(testCase.case, async () => { | |||
it(testCase.case, callback => { |
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.
Why though?
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.
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).
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 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) |
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.
These new events were influenced by https://github.com/adrianhall/winston-splunk-httplogger/blob/main/index.js#L148-L151, https://github.com/TheAppleFreak/winston-slack-webhook-transport/blob/master/slackHook.js#L45-L52 and https://github.com/winstonjs/winston/blob/master/lib/winston/transports/http.js#L57-L61. They also feel useful for supporting #21
No description provided.