Skip to content
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
17 changes: 17 additions & 0 deletions packages/nextjs/src/config/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -445,6 +445,23 @@ export type SentryBuildOptions = {
*/
automaticVercelMonitors?: boolean;

/**
* When an error occurs during release creation or sourcemaps upload, the plugin will call this function.
*
* By default, the plugin will simply throw an error, thereby stopping the bundling process.
* If an `errorHandler` callback is provided, compilation will continue, unless an error is
* thrown in the provided callback.
*
* To allow compilation to continue but still emit a warning, set this option to the following:
*
* ```js
* (err) => {
* console.warn(err);
* }
* ```
*/
errorHandler?: (err: Error) => void;

/**
* Contains a set of experimental flags that might change in future releases. These flags enable
* features that are still in development and may be modified, renamed, or removed without notice.
Expand Down
1 change: 1 addition & 0 deletions packages/nextjs/src/config/webpackPluginOptions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@ export function getWebpackPluginOptions(
project: sentryBuildOptions.project,
telemetry: sentryBuildOptions.telemetry,
debug: sentryBuildOptions.debug,
errorHandler: sentryBuildOptions.errorHandler,
reactComponentAnnotation: {
...sentryBuildOptions.reactComponentAnnotation,
...sentryBuildOptions.unstable_sentryWebpackPluginOptions?.reactComponentAnnotation,
Expand Down
17 changes: 17 additions & 0 deletions packages/nextjs/test/config/webpack/webpackPluginOptions.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -138,6 +138,23 @@ describe('getWebpackPluginOptions()', () => {
});
});

it('forwards errorHandler option', () => {
const buildContext = generateBuildContext({ isServer: false });
const mockErrorHandler = (err: Error) => {
throw err;
};

const generatedPluginOptions = getWebpackPluginOptions(
buildContext,
{
errorHandler: mockErrorHandler,
},
undefined,
);

expect(generatedPluginOptions.errorHandler).toBe(mockErrorHandler);
});

it('returns the right `assets` and `ignore` values during the server build', () => {
const buildContext = generateBuildContext({ isServer: true });
const generatedPluginOptions = getWebpackPluginOptions(buildContext, {}, undefined);
Expand Down
Loading