Skip to content

meta(changelog): Update changelog for 9.26.0 #16480

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

Merged
merged 6 commits into from
Jun 4, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,15 @@
# Changelog

## Unreleased

- "You miss 100 percent of the chances you don't take. — Wayne Gretzky" — Michael Scott
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

thanks for bringing it back :D

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

for reference: this string is used as a detection point for our external contributor action to insert contribution attributions into the changelog automatically


## 9.26.0

- feat(react-router): Re-export functions from `@sentry/react` ([#16465](https://github.com/getsentry/sentry-javascript/pull/16465))
- fix(nextjs): Skip re instrumentating on generate phase of experimental build mode ([#16410](https://github.com/getsentry/sentry-javascript/pull/16410))
- fix(node): Ensure adding sentry-trace and baggage headers via SentryHttpInstrumentation doesn't crash ([#16473](https://github.com/getsentry/sentry-javascript/pull/16473))

## 9.25.1

- fix(otel): Don't ignore child spans after the root is sent ([#16416](https://github.com/getsentry/sentry-javascript/pull/16416))
Expand Down
22 changes: 22 additions & 0 deletions packages/nextjs/src/config/withSentryConfig.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ import { getNextjsVersion } from './util';
import { constructWebpackConfigFunction } from './webpack';

let showedExportModeTunnelWarning = false;
let showedExperimentalBuildModeWarning = false;

/**
* Modifies the passed in Next.js configuration with automatic build-time instrumentation and source map upload.
Expand Down Expand Up @@ -67,6 +68,27 @@ function getFinalConfigObject(
}
}

if (process.argv.includes('--experimental-build-mode')) {
if (!showedExperimentalBuildModeWarning) {
showedExperimentalBuildModeWarning = true;
// eslint-disable-next-line no-console
console.warn(
'[@sentry/nextjs] The Sentry Next.js SDK does not currently fully support next build --experimental-build-mode',
);
}
if (process.argv.includes('generate')) {
// Next.js v15.3.0-canary.1 splits the experimental build into two phases:
// 1. compile: Code compilation
// 2. generate: Environment variable inlining and prerendering (We don't instrument this phase, we inline in the compile phase)
//
// We assume a single “full” build and reruns Webpack instrumentation in both phases.
// During the generate step it collides with Next.js’s inliner
// producing malformed JS and build failures.
// We skip Sentry processing during generate to avoid this issue.
return incomingUserNextConfigObject;
}
}

setUpBuildTimeVariables(incomingUserNextConfigObject, userSentryOptions, releaseName);

const nextJsVersion = getNextjsVersion();
Expand Down
25 changes: 25 additions & 0 deletions packages/nextjs/test/config/withSentryConfig.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -50,4 +50,29 @@ describe('withSentryConfig', () => {

expect(exportedNextConfigFunction).toHaveBeenCalledWith(defaultRuntimePhase, defaultsObject);
});

it('handles experimental build mode correctly', () => {
const originalArgv = process.argv;
const consoleWarnSpy = vi.spyOn(console, 'warn').mockImplementation(() => {});

try {
process.argv = [...originalArgv, '--experimental-build-mode'];
materializeFinalNextConfig(exportedNextConfig);

expect(consoleWarnSpy).toHaveBeenCalledWith(
'[@sentry/nextjs] The Sentry Next.js SDK does not currently fully support next build --experimental-build-mode',
);

// Generate phase
process.argv = [...process.argv, 'generate'];
const generateConfig = materializeFinalNextConfig(exportedNextConfig);

expect(generateConfig).toEqual(exportedNextConfig);

expect(consoleWarnSpy).toHaveBeenCalledTimes(1);
} finally {
process.argv = originalArgv;
consoleWarnSpy.mockRestore();
}
});
});
26 changes: 23 additions & 3 deletions packages/node/src/integrations/http/SentryHttpInstrumentation.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ import {
getSanitizedUrlString,
getTraceData,
httpRequestToRequestData,
isError,
logger,
LRUMap,
parseUrl,
Expand Down Expand Up @@ -262,15 +263,34 @@ export class SentryHttpInstrumentation extends InstrumentationBase<SentryHttpIns

// We do not want to overwrite existing header here, if it was already set
if (sentryTrace && !request.getHeader('sentry-trace')) {
request.setHeader('sentry-trace', sentryTrace);
logger.log(INSTRUMENTATION_NAME, 'Added sentry-trace header to outgoing request');
try {
request.setHeader('sentry-trace', sentryTrace);
DEBUG_BUILD && logger.log(INSTRUMENTATION_NAME, 'Added sentry-trace header to outgoing request');
} catch (error) {
DEBUG_BUILD &&
logger.error(
INSTRUMENTATION_NAME,
'Failed to add sentry-trace header to outgoing request:',
isError(error) ? error.message : 'Unknown error',
);
}
}

if (baggage) {
// For baggage, we make sure to merge this into a possibly existing header
const newBaggage = mergeBaggageHeaders(request.getHeader('baggage'), baggage);
if (newBaggage) {
request.setHeader('baggage', newBaggage);
try {
request.setHeader('baggage', newBaggage);
DEBUG_BUILD && logger.log(INSTRUMENTATION_NAME, 'Added baggage header to outgoing request');
} catch (error) {
DEBUG_BUILD &&
logger.error(
INSTRUMENTATION_NAME,
'Failed to add baggage header to outgoing request:',
isError(error) ? error.message : 'Unknown error',
);
}
}
}
}
Expand Down
7 changes: 4 additions & 3 deletions packages/react-router/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -42,13 +42,14 @@
"@sentry/cli": "^2.45.0",
"@sentry/core": "9.25.1",
"@sentry/node": "9.25.1",
"@sentry/react": "9.25.1",
"@sentry/vite-plugin": "^3.2.4",
"glob": "11.0.1"
},
"devDependencies": {
"@react-router/dev": "^7.1.5",
"@react-router/node": "^7.1.5",
"react-router": "^7.1.5",
"@react-router/dev": "^7.5.2",
"@react-router/node": "^7.5.2",
"react-router": "^7.5.2",
"vite": "^6.1.0"
},
"peerDependencies": {
Expand Down
11 changes: 11 additions & 0 deletions packages/react-router/src/client/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,14 @@ export * from '@sentry/browser';

export { init } from './sdk';
export { reactRouterTracingIntegration } from './tracingIntegration';

export {
captureReactException,
reactErrorHandler,
Profiler,
withProfiler,
useProfiler,
ErrorBoundary,
withErrorBoundary,
} from '@sentry/react';
export type { ErrorBoundaryProps, FallbackRender } from '@sentry/react';
117 changes: 117 additions & 0 deletions packages/react-router/test/client/react-exports.test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,117 @@
import * as SentryReact from '@sentry/react';
import { render } from '@testing-library/react';
import * as React from 'react';
import { afterEach, describe, expect, it, vi } from 'vitest';
import type { ErrorBoundaryProps, FallbackRender } from '../../src/client';
import {
captureReactException,
ErrorBoundary,
Profiler,
reactErrorHandler,
useProfiler,
withErrorBoundary,
withProfiler,
} from '../../src/client';

describe('Re-exports from React SDK', () => {
afterEach(() => {
vi.clearAllMocks();
});

describe('re-export integrity', () => {
it('should have the same reference as original @sentry/react exports', () => {
// Ensure we are re-exporting the exact same functions/components, not copies
expect(captureReactException).toBe(SentryReact.captureReactException);
expect(reactErrorHandler).toBe(SentryReact.reactErrorHandler);
expect(Profiler).toBe(SentryReact.Profiler);
expect(withProfiler).toBe(SentryReact.withProfiler);
expect(useProfiler).toBe(SentryReact.useProfiler);
expect(ErrorBoundary).toBe(SentryReact.ErrorBoundary);
expect(withErrorBoundary).toBe(SentryReact.withErrorBoundary);
});
});

describe('function exports', () => {
it('captureReactException should work when called', () => {
const error = new Error('test error');
const errorInfo = { componentStack: 'component stack' };

const result = captureReactException(error, errorInfo);
expect(typeof result).toBe('string');
expect(result).toMatch(/^[a-f0-9]{32}$/); // assuming event ID is a 32-character hex string
});
});

describe('component exports', () => {
it('ErrorBoundary should render children when no error occurs', () => {
const { getByText } = render(
React.createElement(
ErrorBoundary,
{ fallback: () => React.createElement('div', null, 'Error occurred') },
React.createElement('div', null, 'Child content'),
),
);

expect(getByText('Child content')).toBeDefined();
});

it('Profiler should render children', () => {
const { getByText } = render(
React.createElement(
Profiler,
{ name: 'TestProfiler', updateProps: {} },
React.createElement('div', null, 'Profiled content'),
),
);

expect(getByText('Profiled content')).toBeDefined();
});
});

describe('HOC exports', () => {
it('withErrorBoundary should create a wrapped component', () => {
const TestComponent = () => React.createElement('div', null, 'ErrorBoundary Test Component');
const WrappedComponent = withErrorBoundary(TestComponent, {
fallback: () => React.createElement('div', null, 'Error occurred'),
});

expect(WrappedComponent).toBeDefined();
expect(typeof WrappedComponent).toBe('function');
expect(WrappedComponent.displayName).toBe('errorBoundary(TestComponent)');

const { getByText } = render(React.createElement(WrappedComponent));
expect(getByText('ErrorBoundary Test Component')).toBeDefined();
});

it('withProfiler should create a wrapped component', () => {
const TestComponent = () => React.createElement('div', null, 'Profiler Test Component');
const WrappedComponent = withProfiler(TestComponent, { name: 'TestComponent' });

expect(WrappedComponent).toBeDefined();
expect(typeof WrappedComponent).toBe('function');
expect(WrappedComponent.displayName).toBe('profiler(TestComponent)');

const { getByText } = render(React.createElement(WrappedComponent));
expect(getByText('Profiler Test Component')).toBeDefined();
});
});

describe('type exports', () => {
it('should export ErrorBoundaryProps type', () => {
// This is a compile-time test - if this compiles, the type is exported correctly
const props: ErrorBoundaryProps = {
children: React.createElement('div'),
fallback: () => React.createElement('div', null, 'Error'),
};
expect(props).toBeDefined();
});

it('should export FallbackRender type', () => {
// This is a compile-time test - if this compiles, the type is exported correctly
const fallbackRender: FallbackRender = ({ error }) =>
React.createElement('div', null, `Error: ${error?.toString()}`);
expect(fallbackRender).toBeDefined();
expect(typeof fallbackRender).toBe('function');
});
});
});
Loading
Loading