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(transport): Return result through Transport send #6626
Conversation
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 only real risk I see here is if customers are manually calling transport.send and have come to expect that it never throws.
So this could be considered behaviorally breaking, for custom transport implementations based on the base transport, right?
Any chance that we can still return the response and not throw? Or do you need it to throw for your transport?
No, this does not change the behaviour, or expected behaviour of any existing transports or custom transports. A custom Re-throwing the error here will only impact those that call the |
Do you have a plan on doing something when the error is thrown? Otherwise I would just leave it be for now. |
Yes, since an exception is the main failure mode for most of the We don't actually care about the exception type or any of the details though so I could alternatively include a flag in export type TransportMakeRequestResponse = {
statusCode?: number;
headers?: {
[key: string]: string | null;
'x-sentry-rate-limits': string | null;
'retry-after': string | null;
};
failed?: true
}; So in The main issue with this is that it might be confusing to those who are implementing transports. Should your custom transport throw or return |
Ok thought about this way longer than I probably should. I think throwing is fine and it might have even been an oversight not to throw there in the first place. The only thing I would do is remove the log message on line 89 to only log in the place where we're actually handling the error. The same sentiment goes towards returning the result. We should probably have made I say let's go through with it! |
Oh yes, this will result in logging the error twice!
I'll add a |
For it to be possible to wrap the transport for offline support (#6403), wrapping transports need to be able to cater for rate limiting and therefore
send
needs to returnTransportMakeRequestResponse
rather thanvoid
. To move in this direction while minimising breaking changes, this PR changes the return toPromise<void | TransportMakeRequestResponse>
.This PR changes the logic so that
send
now throws in failure cases. This is not a concern for internal code because the two places it's called errors are caught and logged:sentry-javascript/packages/core/src/baseclient.ts
Lines 739 to 741 in 36488ec
sentry-javascript/packages/replay/src/replay.ts
Lines 994 to 998 in 371d42d
The only real risk I see here is if customers are manually calling
transport.send
and have come to expect that it never throws.