-
-
Notifications
You must be signed in to change notification settings - Fork 1.8k
Description
Is there an existing issue for this?
- I have checked for existing issues https://github.com/getsentry/sentry-javascript/issues
- I have reviewed the documentation https://docs.sentry.io/
- I am using the latest SDK release https://github.com/getsentry/sentry-javascript/releases
How do you use Sentry?
Sentry Saas (sentry.io)
Which SDK are you using?
@sentry/browser
SDK Version
10.38.0
Framework Version
No response
Link to Sentry event
No response
Reproduction Example/SDK Setup
This code is accepted by TypeScript, but throws Uncaught TypeError: jqXHR.abort is not a function at runtime.
import * as Sentry from "@sentry/core";
import $ from "jquery";
const jqXHR = Sentry.startSpan({ name: "test" }, () =>
$.ajax("https://http.codes/200"),
);
jqXHR.abort();$.ajax() returns a jqXHR object that’s a superset of both Promise and XMLHTTPRequest. However, Sentry’s maybeHandlePromiseRejection(value) wraps the Promise part using .then(…) without preserving the XMLHTTPRequest part of the interface. So its type annotation claiming that it returns the same type as value is incorrect (masked by // @ts-expect-error).
(This leads to a bug in Zulip.)
Steps to Reproduce
Open this HTML page in a browser and look at the console:
<!doctype html>
<title>Test</title>
<script type="module">
import * as Sentry from "https://esm.sh/@sentry/core";
import $ from "https://esm.sh/jquery";
const jqXHR = Sentry.startSpan({ name: "test" }, () =>
$.ajax("https://http.codes/200"),
);
jqXHR.abort();
</script>Expected Result
Either
- this should run successfully at runtime (perhaps
maybeHandlePromiseRejectioncould allow the wrapped promise to float and return the original promise-like object instead); or - this should not be accepted by TypeScript (perhaps using a return type like
value extends PromiseLike<infer T> ? PromiseLike<Awaited<T>> : T).
Actual Result
Uncaught TypeError: jqXHR.abort is not a function
Additional Context
No response
Priority
React with 👍 to help prioritize this issue. Please use comments to provide useful context, avoiding +1 or me too, to help us triage it.
Metadata
Metadata
Assignees
Projects
Status