@@ -2,7 +2,7 @@ import { context } from '@opentelemetry/api';
2
2
import { isTracingSuppressed , VERSION } from '@opentelemetry/core' ;
3
3
import type { InstrumentationConfig } from '@opentelemetry/instrumentation' ;
4
4
import { InstrumentationBase } from '@opentelemetry/instrumentation' ;
5
- import type { SanitizedRequestData } from '@sentry/core' ;
5
+ import { isSentryRequestUrl , SanitizedRequestData } from '@sentry/core' ;
6
6
import {
7
7
addBreadcrumb ,
8
8
getBreadcrumbLogLevelFromHttpStatusCode ,
@@ -17,7 +17,6 @@ import * as diagch from 'diagnostics_channel';
17
17
import { NODE_MAJOR , NODE_MINOR } from '../../nodeVersion' ;
18
18
import { mergeBaggageHeaders } from '../../utils/baggage' ;
19
19
import type { UndiciRequest , UndiciResponse } from './types' ;
20
- import { isNextEdgeRuntime } from '../../utils/isNextEdgeRuntime' ;
21
20
22
21
const SENTRY_TRACE_HEADER = 'sentry-trace' ;
23
22
const SENTRY_BAGGAGE_HEADER = 'baggage' ;
@@ -239,17 +238,21 @@ export class SentryNodeFetchInstrumentation extends InstrumentationBase<SentryNo
239
238
* Check if the given outgoing request should be ignored.
240
239
*/
241
240
private _shouldIgnoreOutgoingRequest ( request : UndiciRequest ) : boolean {
242
- // Never instrument outgoing requests in Edge Runtime
243
- // This can be a problem when running in Next.js Edge Runtime in dev,
244
- // as there edge is simulated but still uses Node under the hood, leaving to problems
245
- if ( isTracingSuppressed ( context . active ( ) ) || isNextEdgeRuntime ( ) ) {
241
+ if ( isTracingSuppressed ( context . active ( ) ) ) {
246
242
return true ;
247
243
}
248
244
249
245
// Add trace propagation headers
250
246
const url = getAbsoluteUrl ( request . origin , request . path ) ;
251
247
const ignoreOutgoingRequests = this . getConfig ( ) . ignoreOutgoingRequests ;
252
248
249
+ // Normally, we should not need this, because `suppressTracing` should take care of this
250
+ // However, in Next.js Edge Runtime in dev, there is a bug where the edge is simulated but still uses Node under the hood, leading to problems
251
+ // So we make sure to ignore outgoing requests to Sentry endpoints
252
+ if ( isSentryRequestUrl ( url , getClient ( ) ) ) {
253
+ return true ;
254
+ }
255
+
253
256
if ( typeof ignoreOutgoingRequests !== 'function' || ! url ) {
254
257
return false ;
255
258
}
0 commit comments