-
-
Notifications
You must be signed in to change notification settings - Fork 1.7k
Closed
Description
- Review the documentation: https://docs.sentry.io/
- Search for existing issues: https://github.com/getsentry/sentry-javascript/issues
- Use the latest release: https://github.com/getsentry/sentry-javascript/releases
- Provide a link to the affected event from your Sentry account: There is no event, the library just errors
Package + Version
-
@sentry/browser -
@sentry/node -
raven-js -
raven-node(raven for node) - other:
@sentry/apm
Version:
5.17.0
Description
The ApmIntegrations.Tracing doesn't handle headers properly in fetch when it is supplied as an array or as a Headers object:
import * as Sentry from '@sentry/browser';
import { Integrations as ApmIntegrations } from '@sentry/apm';
Sentry.init({
// ...
integrations: [new ApmIntegrations.Tracing()]
});In the following case, the headers are cleared by the tracing integration:
await fetch('/', { headers: new Headers({ 'content-type': 'application/json' }) })In the following case, it downright errors:
await fetch('/', { headers: [['content-type', 'application/json']] })
// Uncaught (in promise) TypeError: Failed to execute 'fetch' on 'Window': The object must have a callable @@iterator property.This just flat out started to break our application in production for some of our users, with no indication whatsoever as to what causes this.
From digging through the code, I think the problem comes from here. Didn't test this, but I think something like the following should work:
if (options.headers && typeof options.headers[Symbol.iterator] === 'function') {
options.headers = [...options.headers, ['sentry-trace', span.toTraceparent()]];
} else {
options.headers = {
...options.headers,
'sentry-trace': span.toTraceparent(),
};
}Looking at the code it seems like it would also incorrectly handle
await fetch(new Request('/', { headers: new Headers({ 'content-type': 'application/json' }) }))Metadata
Metadata
Assignees
Labels
No labels