-
Notifications
You must be signed in to change notification settings - Fork 29
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
feat: #146 async send support #181
Conversation
customData?: CustomData, | ||
callback?: (err: Error | null) => void, | ||
request?: RequestParams, | ||
tags?: Tag[], | ||
): void { | ||
const result = this.buildSendOptions( | ||
exception, | ||
customData, | ||
callback, | ||
request, | ||
tags, |
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.
Removed all the unused parameters, although this would be out of scope for this PR
this.send(err, customData || {}, requestParams, [ | ||
"UnhandledException", | ||
]); | ||
]).catch((err) => { | ||
console.log(`[Raygun] Failed to send Express error: ${err}`); | ||
}); |
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 is internal to the express
error handler.
const send = (e) => | ||
new Promise((resolve, reject) => { | ||
raygunClient.send(e, null, (err, data) => { | ||
if (err) { | ||
reject(err); | ||
} else { | ||
resolve(data); | ||
} | ||
}); | ||
}); | ||
|
||
await send(new Error("offline error")); |
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 is no longer necessary, because now the raygunClient.send
method is asynchronous
@@ -27,7 +27,7 @@ test("send basic", {}, function (t) { | |||
var client = new Raygun.Client().init({ | |||
apiKey: API_KEY, | |||
}); | |||
client.send(new Error(), {}, function (response) { | |||
client.sendWithCallback(new Error(), {}, function (response) { |
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.
The old raygun_send_test
still uses the legacy sendWithCallback
method, this test fine can be removed when the sendWithCallback
method is finally removed.
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.
Implementation overall LGTM! Nice work on downsizing the send call 💪
Co-authored-by: Sumitra Manga <[email protected]>
I need a new review... 🙃 The tickets have been created, I'll edit them with some extra info. |
What's the ETA on getting this merged and released? I'm super keen to try it out and get it hooked into Winston as a custom transport. |
Hi @paul-uz we are talking internally that we want to do a pre-release with these changes once they are merged in. I'll try to remember to ping you when we have it ready, and be looking forward to your feedback! |
Please do what you can to extradite this ✌️ |
Just double checking - Did you turn all to do's into an Issue? |
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.
Thank you for the changes and making those Issues! LGTM🍾
yes, I did! |
@miquelbeltran how long until a new release version is out? |
feat: #146 async send support
Description 📝
send
API methodsend
assendWithCallback
and create a newsend
async method..send()
does not with without async/await. #141Note: the client requires a major clean-up to fully remove all callbacks from the internal implementation. This will be done in separated PRs after this one.
Type of change
Updates
send
with a callback was renamed tosendWithCallback
, it is still being used internally, so it was hard to fully remove the existing callback parameter without doing a major package rewrite.send
method that supports awaited calls.Promise
that can be anIncomingMessage
. Users can ignore this response if they want, or used to verify that the error was sent correctly to Raygun.Promise
will be "rejected", users can catch this error. The error payload can be eitherError & IncomingMessage
or justError
.Promise
constructor, wrapping the legacysendWithCallback
method.Other changes:
send
implementations, they still use callbacks internally, and will require a lot of work to clean up. This work should be done in small batches split in several PRs.README.md
with usage examples.examples/using-domains
.send()
method directly.Test plan 🧪
raygun_send_test
but for asyncsend
calls.examples/using-domains
, which now uses the asyncsend
method.Author to check 👓
Reviewer to check ✔️