Socket
Socket
Sign inDemoInstall

@sentry/nextjs

Package Overview
Dependencies
Maintainers
11
Versions
309
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@sentry/nextjs - npm Package Compare versions

Comparing version 8.4.0 to 8.5.0

cjs/common/utils/vercelWaitUntil.js

5

cjs/common/_error.js

@@ -5,2 +5,3 @@ Object.defineProperty(exports, '__esModule', { value: true });

const responseEnd = require('./utils/responseEnd.js');
const vercelWaitUntil = require('./utils/vercelWaitUntil.js');

@@ -50,5 +51,3 @@ /**

// In case this is being run as part of a serverless function (as is the case with the server half of nextjs apps
// deployed to vercel), make sure the error gets sent to Sentry before the lambda exits.
await responseEnd.flushQueue();
vercelWaitUntil.vercelWaitUntil(responseEnd.flushSafelyWithTimeout());
}

@@ -55,0 +54,0 @@

7

cjs/common/utils/edgeWrapperUtils.js

@@ -7,2 +7,3 @@ Object.defineProperty(exports, '__esModule', { value: true });

const tracingUtils = require('./tracingUtils.js');
const vercelWaitUntil = require('./vercelWaitUntil.js');

@@ -74,5 +75,7 @@ /**

},
).finally(() => responseEnd.flushQueue());
);
},
);
).finally(() => {
vercelWaitUntil.vercelWaitUntil(responseEnd.flushSafelyWithTimeout());
});
});

@@ -79,0 +82,0 @@ });

@@ -45,6 +45,10 @@ Object.defineProperty(exports, '__esModule', { value: true });

/** Flush the event queue to ensure that events get sent to Sentry before the response is finished and the lambda ends */
async function flushQueue() {
/**
* Flushes pending Sentry events with a 2 second timeout and in a way that cannot create unhandled promise rejections.
*/
async function flushSafelyWithTimeout() {
try {
debugBuild.DEBUG_BUILD && utils.logger.log('Flushing events...');
// We give things that are currently stuck in event processors a tiny bit more time to finish before flushing. 50ms was chosen very unscientifically.
await new Promise(resolve => setTimeout(resolve, 50));
await core.flush(2000);

@@ -59,3 +63,3 @@ debugBuild.DEBUG_BUILD && utils.logger.log('Done flushing events');

exports.finishSpan = finishSpan;
exports.flushQueue = flushQueue;
exports.flushSafelyWithTimeout = flushSafelyWithTimeout;
//# sourceMappingURL=responseEnd.js.map

@@ -9,5 +9,5 @@ var {

const utils = require('@sentry/utils');
const platformSupportsStreaming = require('./platformSupportsStreaming.js');
const responseEnd = require('./responseEnd.js');
const tracingUtils = require('./tracingUtils.js');
const vercelWaitUntil = require('./vercelWaitUntil.js');

@@ -108,5 +108,2 @@ /**

dataFetcherSpan.end();
if (!platformSupportsStreaming.platformSupportsStreaming()) {
await responseEnd.flushQueue();
}
}

@@ -118,2 +115,4 @@ },

});
}).finally(() => {
vercelWaitUntil.vercelWaitUntil(responseEnd.flushSafelyWithTimeout());
});

@@ -183,8 +182,7 @@ };

dataFetcherSpan.end();
if (!platformSupportsStreaming.platformSupportsStreaming()) {
await responseEnd.flushQueue();
}
}
},
);
).finally(() => {
vercelWaitUntil.vercelWaitUntil(responseEnd.flushSafelyWithTimeout());
});
}

@@ -191,0 +189,0 @@

@@ -12,5 +12,5 @@ var {

const nextNavigationErrorUtils = require('./nextNavigationErrorUtils.js');
const platformSupportsStreaming = require('./utils/platformSupportsStreaming.js');
const responseEnd = require('./utils/responseEnd.js');
const tracingUtils = require('./utils/tracingUtils.js');
const vercelWaitUntil = require('./utils/vercelWaitUntil.js');

@@ -116,12 +116,3 @@ /**

} finally {
if (!platformSupportsStreaming.platformSupportsStreaming()) {
// Lambdas require manual flushing to prevent execution freeze before the event is sent
await responseEnd.flushQueue();
}
if (process.env.NEXT_RUNTIME === 'edge') {
// flushQueue should not throw
// eslint-disable-next-line @typescript-eslint/no-floating-promises
responseEnd.flushQueue();
}
vercelWaitUntil.vercelWaitUntil(responseEnd.flushSafelyWithTimeout());
}

@@ -128,0 +119,0 @@ },

@@ -9,5 +9,5 @@ var {

const utils = require('@sentry/utils');
const platformSupportsStreaming = require('./utils/platformSupportsStreaming.js');
const responseEnd = require('./utils/responseEnd.js');
const tracingUtils = require('./utils/tracingUtils.js');
const vercelWaitUntil = require('./utils/vercelWaitUntil.js');

@@ -83,11 +83,4 @@ /**

span.end();
if (platformSupportsStreaming.platformSupportsStreaming() && !wrappingTarget.__sentry_test_doesnt_support_streaming__) {
target.apply(thisArg, argArray);
} else {
// flushQueue will not reject
// eslint-disable-next-line @typescript-eslint/no-floating-promises
responseEnd.flushQueue().then(() => {
target.apply(thisArg, argArray);
});
}
vercelWaitUntil.vercelWaitUntil(responseEnd.flushSafelyWithTimeout());
target.apply(thisArg, argArray);
},

@@ -139,10 +132,3 @@ });

// Make sure we have a chance to finish the transaction and flush events to Sentry before the handler errors
// out. (Apps which are deployed on Vercel run their API routes in lambdas, and those lambdas will shut down the
// moment they detect an error, so it's important to get this done before rethrowing the error. Apps not
// deployed serverlessly will run into this cleanup code again in `res.end(), but the transaction will already
// be finished and the queue will already be empty, so effectively it'll just no-op.)
if (platformSupportsStreaming.platformSupportsStreaming() && !wrappingTarget.__sentry_test_doesnt_support_streaming__) {
await responseEnd.flushQueue();
}
vercelWaitUntil.vercelWaitUntil(responseEnd.flushSafelyWithTimeout());

@@ -149,0 +135,0 @@ // We rethrow here so that nextjs can do with the error whatever it would normally do. (Sometimes "whatever it

@@ -6,5 +6,5 @@ Object.defineProperty(exports, '__esModule', { value: true });

const nextNavigationErrorUtils = require('./nextNavigationErrorUtils.js');
const platformSupportsStreaming = require('./utils/platformSupportsStreaming.js');
const responseEnd = require('./utils/responseEnd.js');
const tracingUtils = require('./utils/tracingUtils.js');
const vercelWaitUntil = require('./utils/vercelWaitUntil.js');

@@ -87,7 +87,3 @@ /**

} finally {
if (!platformSupportsStreaming.platformSupportsStreaming() || process.env.NEXT_RUNTIME === 'edge') {
// 1. Edge transport requires manual flushing
// 2. Lambdas require manual flushing to prevent execution freeze before the event is sent
await responseEnd.flushQueue();
}
vercelWaitUntil.vercelWaitUntil(responseEnd.flushSafelyWithTimeout());
}

@@ -94,0 +90,0 @@ });

@@ -12,2 +12,3 @@ var {

const tracingUtils = require('./utils/tracingUtils.js');
const vercelWaitUntil = require('./utils/vercelWaitUntil.js');

@@ -86,6 +87,3 @@ /**

span.end();
// flushQueue should not throw
// eslint-disable-next-line @typescript-eslint/no-floating-promises
responseEnd.flushQueue();
vercelWaitUntil.vercelWaitUntil(responseEnd.flushSafelyWithTimeout());
},

@@ -92,0 +90,0 @@ );

@@ -157,3 +157,3 @@ var {

core.addEventProcessor(
core.getGlobalScope().addEventProcessor(
Object.assign(

@@ -196,4 +196,29 @@ (event => {

core.getGlobalScope().addEventProcessor(
Object.assign(
((event, hint) => {
if (event.type !== undefined) {
return event;
}
const originalException = hint.originalException;
const isReactControlFlowError =
typeof originalException === 'object' &&
originalException !== null &&
'$$typeof' in originalException &&
originalException.$$typeof === Symbol.for('react.postpone');
if (isReactControlFlowError) {
return null;
}
return event;
}) ,
{ id: 'DropReactControlFlowErrors' },
),
);
if (process.env.NODE_ENV === 'development') {
core.addEventProcessor(devErrorSymbolicationEventProcessor.devErrorSymbolicationEventProcessor);
core.getGlobalScope().addEventProcessor(devErrorSymbolicationEventProcessor.devErrorSymbolicationEventProcessor);
}

@@ -200,0 +225,0 @@

import { withScope, captureException } from '@sentry/core';
import { flushQueue } from './utils/responseEnd.js';
import { flushSafelyWithTimeout } from './utils/responseEnd.js';
import { vercelWaitUntil } from './utils/vercelWaitUntil.js';

@@ -47,5 +48,3 @@ /**

// In case this is being run as part of a serverless function (as is the case with the server half of nextjs apps
// deployed to vercel), make sure the error gets sent to Sentry before the lambda exits.
await flushQueue();
vercelWaitUntil(flushSafelyWithTimeout());
}

@@ -52,0 +51,0 @@

import { withIsolationScope, continueTrace, startSpan, SEMANTIC_ATTRIBUTE_SENTRY_SOURCE, SEMANTIC_ATTRIBUTE_SENTRY_ORIGIN, handleCallbackErrors, captureException, setHttpStatus, SPAN_STATUS_OK } from '@sentry/core';
import { winterCGRequestToRequestData } from '@sentry/utils';
import { flushQueue } from './responseEnd.js';
import { flushSafelyWithTimeout } from './responseEnd.js';
import { escapeNextjsTracing, commonObjectToIsolationScope } from './tracingUtils.js';
import { vercelWaitUntil } from './vercelWaitUntil.js';

@@ -71,5 +72,7 @@ /**

},
).finally(() => flushQueue());
);
},
);
).finally(() => {
vercelWaitUntil(flushSafelyWithTimeout());
});
});

@@ -76,0 +79,0 @@ });

@@ -43,6 +43,10 @@ import { flush, setHttpStatus } from '@sentry/core';

/** Flush the event queue to ensure that events get sent to Sentry before the response is finished and the lambda ends */
async function flushQueue() {
/**
* Flushes pending Sentry events with a 2 second timeout and in a way that cannot create unhandled promise rejections.
*/
async function flushSafelyWithTimeout() {
try {
DEBUG_BUILD && logger.log('Flushing events...');
// We give things that are currently stuck in event processors a tiny bit more time to finish before flushing. 50ms was chosen very unscientifically.
await new Promise(resolve => setTimeout(resolve, 50));
await flush(2000);

@@ -55,3 +59,3 @@ DEBUG_BUILD && logger.log('Done flushing events');

export { autoEndSpanOnResponseEnd, finishSpan, flushQueue };
export { autoEndSpanOnResponseEnd, finishSpan, flushSafelyWithTimeout };
//# sourceMappingURL=responseEnd.js.map
import { _optionalChain } from '@sentry/utils';
import { withIsolationScope, continueTrace, withActiveSpan, startSpanManual, SEMANTIC_ATTRIBUTE_SENTRY_ORIGIN, SEMANTIC_ATTRIBUTE_SENTRY_SOURCE, SPAN_STATUS_OK, SPAN_STATUS_ERROR, startInactiveSpan, startSpan, captureException } from '@sentry/core';
import { isString } from '@sentry/utils';
import { platformSupportsStreaming } from './platformSupportsStreaming.js';
import { flushQueue, autoEndSpanOnResponseEnd } from './responseEnd.js';
import { flushSafelyWithTimeout, autoEndSpanOnResponseEnd } from './responseEnd.js';
import { escapeNextjsTracing, commonObjectToIsolationScope } from './tracingUtils.js';
import { vercelWaitUntil } from './vercelWaitUntil.js';

@@ -102,5 +102,2 @@ /**

dataFetcherSpan.end();
if (!platformSupportsStreaming()) {
await flushQueue();
}
}

@@ -112,2 +109,4 @@ },

});
}).finally(() => {
vercelWaitUntil(flushSafelyWithTimeout());
});

@@ -177,8 +176,7 @@ };

dataFetcherSpan.end();
if (!platformSupportsStreaming()) {
await flushQueue();
}
}
},
);
).finally(() => {
vercelWaitUntil(flushSafelyWithTimeout());
});
}

@@ -185,0 +183,0 @@

@@ -6,5 +6,5 @@ import { _nullishCoalesce, _optionalChain } from '@sentry/utils';

import { isNotFoundNavigationError, isRedirectNavigationError } from './nextNavigationErrorUtils.js';
import { platformSupportsStreaming } from './utils/platformSupportsStreaming.js';
import { flushQueue } from './utils/responseEnd.js';
import { flushSafelyWithTimeout } from './utils/responseEnd.js';
import { escapeNextjsTracing } from './utils/tracingUtils.js';
import { vercelWaitUntil } from './utils/vercelWaitUntil.js';

@@ -110,12 +110,3 @@ /**

} finally {
if (!platformSupportsStreaming()) {
// Lambdas require manual flushing to prevent execution freeze before the event is sent
await flushQueue();
}
if (process.env.NEXT_RUNTIME === 'edge') {
// flushQueue should not throw
// eslint-disable-next-line @typescript-eslint/no-floating-promises
flushQueue();
}
vercelWaitUntil(flushSafelyWithTimeout());
}

@@ -122,0 +113,0 @@ },

import { _optionalChain } from '@sentry/utils';
import { withIsolationScope, continueTrace, startSpanManual, SEMANTIC_ATTRIBUTE_SENTRY_SOURCE, SEMANTIC_ATTRIBUTE_SENTRY_ORIGIN, setHttpStatus, captureException } from '@sentry/core';
import { logger, isString, consoleSandbox, objectify } from '@sentry/utils';
import { platformSupportsStreaming } from './utils/platformSupportsStreaming.js';
import { flushQueue } from './utils/responseEnd.js';
import { flushSafelyWithTimeout } from './utils/responseEnd.js';
import { escapeNextjsTracing } from './utils/tracingUtils.js';
import { vercelWaitUntil } from './utils/vercelWaitUntil.js';

@@ -77,11 +77,4 @@ /**

span.end();
if (platformSupportsStreaming() && !wrappingTarget.__sentry_test_doesnt_support_streaming__) {
target.apply(thisArg, argArray);
} else {
// flushQueue will not reject
// eslint-disable-next-line @typescript-eslint/no-floating-promises
flushQueue().then(() => {
target.apply(thisArg, argArray);
});
}
vercelWaitUntil(flushSafelyWithTimeout());
target.apply(thisArg, argArray);
},

@@ -133,10 +126,3 @@ });

// Make sure we have a chance to finish the transaction and flush events to Sentry before the handler errors
// out. (Apps which are deployed on Vercel run their API routes in lambdas, and those lambdas will shut down the
// moment they detect an error, so it's important to get this done before rethrowing the error. Apps not
// deployed serverlessly will run into this cleanup code again in `res.end(), but the transaction will already
// be finished and the queue will already be empty, so effectively it'll just no-op.)
if (platformSupportsStreaming() && !wrappingTarget.__sentry_test_doesnt_support_streaming__) {
await flushQueue();
}
vercelWaitUntil(flushSafelyWithTimeout());

@@ -143,0 +129,0 @@ // We rethrow here so that nextjs can do with the error whatever it would normally do. (Sometimes "whatever it

import { withIsolationScope, withScope, startSpan, SEMANTIC_ATTRIBUTE_SENTRY_SOURCE, SEMANTIC_ATTRIBUTE_SENTRY_OP, SEMANTIC_ATTRIBUTE_SENTRY_ORIGIN, handleCallbackErrors, SPAN_STATUS_ERROR, captureException, setHttpStatus } from '@sentry/core';
import { winterCGHeadersToDict, propagationContextFromHeaders } from '@sentry/utils';
import { isRedirectNavigationError, isNotFoundNavigationError } from './nextNavigationErrorUtils.js';
import { platformSupportsStreaming } from './utils/platformSupportsStreaming.js';
import { flushQueue } from './utils/responseEnd.js';
import { flushSafelyWithTimeout } from './utils/responseEnd.js';
import { escapeNextjsTracing, commonObjectToIsolationScope, commonObjectToPropagationContext } from './utils/tracingUtils.js';
import { vercelWaitUntil } from './utils/vercelWaitUntil.js';

@@ -84,7 +84,3 @@ /**

} finally {
if (!platformSupportsStreaming() || process.env.NEXT_RUNTIME === 'edge') {
// 1. Edge transport requires manual flushing
// 2. Lambdas require manual flushing to prevent execution freeze before the event is sent
await flushQueue();
}
vercelWaitUntil(flushSafelyWithTimeout());
}

@@ -91,0 +87,0 @@ });

@@ -5,4 +5,5 @@ import { _optionalChain } from '@sentry/utils';

import { isNotFoundNavigationError, isRedirectNavigationError } from './nextNavigationErrorUtils.js';
import { flushQueue } from './utils/responseEnd.js';
import { flushSafelyWithTimeout } from './utils/responseEnd.js';
import { escapeNextjsTracing, commonObjectToIsolationScope, commonObjectToPropagationContext } from './utils/tracingUtils.js';
import { vercelWaitUntil } from './utils/vercelWaitUntil.js';

@@ -81,6 +82,3 @@ /**

span.end();
// flushQueue should not throw
// eslint-disable-next-line @typescript-eslint/no-floating-promises
flushQueue();
vercelWaitUntil(flushSafelyWithTimeout());
},

@@ -87,0 +85,0 @@ );

import { _optionalChain } from '@sentry/utils';
import { applySdkMetadata, getClient, addEventProcessor } from '@sentry/core';
import { applySdkMetadata, getClient, getGlobalScope } from '@sentry/core';
import { getDefaultIntegrations, init as init$1 } from '@sentry/node';

@@ -153,3 +153,3 @@ export * from '@sentry/node';

addEventProcessor(
getGlobalScope().addEventProcessor(
Object.assign(

@@ -192,4 +192,29 @@ (event => {

getGlobalScope().addEventProcessor(
Object.assign(
((event, hint) => {
if (event.type !== undefined) {
return event;
}
const originalException = hint.originalException;
const isReactControlFlowError =
typeof originalException === 'object' &&
originalException !== null &&
'$$typeof' in originalException &&
originalException.$$typeof === Symbol.for('react.postpone');
if (isReactControlFlowError) {
return null;
}
return event;
}) ,
{ id: 'DropReactControlFlowErrors' },
),
);
if (process.env.NODE_ENV === 'development') {
addEventProcessor(devErrorSymbolicationEventProcessor);
getGlobalScope().addEventProcessor(devErrorSymbolicationEventProcessor);
}

@@ -196,0 +221,0 @@

{
"name": "@sentry/nextjs",
"version": "8.4.0",
"version": "8.5.0",
"description": "Official Sentry SDK for Next.js",

@@ -70,9 +70,9 @@ "repository": "git://github.com/getsentry/sentry-javascript.git",

"@rollup/plugin-commonjs": "24.0.0",
"@sentry/core": "8.4.0",
"@sentry/node": "8.4.0",
"@sentry/opentelemetry": "8.4.0",
"@sentry/react": "8.4.0",
"@sentry/types": "8.4.0",
"@sentry/utils": "8.4.0",
"@sentry/vercel-edge": "8.4.0",
"@sentry/core": "8.5.0",
"@sentry/node": "8.5.0",
"@sentry/opentelemetry": "8.5.0",
"@sentry/react": "8.5.0",
"@sentry/types": "8.5.0",
"@sentry/utils": "8.5.0",
"@sentry/vercel-edge": "8.5.0",
"@sentry/webpack-plugin": "2.16.0",

@@ -79,0 +79,0 @@ "chalk": "3.0.0",

@@ -28,6 +28,2 @@ import { SentrySpan } from '@sentry/core';

__sentry_route__?: string;
/**
* A property we set in our integration tests to simulate running an API route on platforms that don't support streaming.
*/
__sentry_test_doesnt_support_streaming__?: true;
};

@@ -34,0 +30,0 @@ export type WrappedNextApiHandler = {

@@ -24,4 +24,6 @@ /// <reference types="node" />

export declare function finishSpan(span: Span, res: ServerResponse): void;
/** Flush the event queue to ensure that events get sent to Sentry before the response is finished and the lambda ends */
export declare function flushQueue(): Promise<void>;
/**
* Flushes pending Sentry events with a 2 second timeout and in a way that cannot create unhandled promise rejections.
*/
export declare function flushSafelyWithTimeout(): Promise<void>;
//# sourceMappingURL=responseEnd.d.ts.map

@@ -28,6 +28,2 @@ import type { SentrySpan } from '@sentry/core';

__sentry_route__?: string;
/**
* A property we set in our integration tests to simulate running an API route on platforms that don't support streaming.
*/
__sentry_test_doesnt_support_streaming__?: true;
};

@@ -34,0 +30,0 @@ export type WrappedNextApiHandler = {

@@ -24,4 +24,6 @@ /// <reference types="node" />

export declare function finishSpan(span: Span, res: ServerResponse): void;
/** Flush the event queue to ensure that events get sent to Sentry before the response is finished and the lambda ends */
export declare function flushQueue(): Promise<void>;
/**
* Flushes pending Sentry events with a 2 second timeout and in a way that cannot create unhandled promise rejections.
*/
export declare function flushSafelyWithTimeout(): Promise<void>;
//# sourceMappingURL=responseEnd.d.ts.map

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc