Running into an issue capturing console errors with Sentry in a Next.js app.
The problem arises from an error within a library that is inaccessible to us, specifically related to WebSocket
"WebSocket is already in CLOSING or CLOSED state"
This error is clearly visible in the Chrome debug panel https://i.sstatic.net/mnDAq.png
However, it seems that this error is not being sent to Sentry despite initializing it with the following code in next.config.js
const withPlugins = require('next-compose-plugins');
const { withSentryConfig } = require('@sentry/nextjs');
const { CaptureConsole } = require('@sentry/integrations');
...
module.exports = withPlugins(
[
[(config) => withSentryConfig(config, sentryOptions), {}]
],
nextConfig,
);
The configuration in sentry.client.config.js
includes:
import * as Sentry from '@sentry/nextjs';
import { CaptureConsole } from '@sentry/integrations';
import { Integrations } from '@sentry/tracing';
...
Despite other console.error
messages being successfully sent to Sentry, this particular error is not. Could it be that it's not directly logged using console.error
and is handled at a lower level? How can we ensure this error is properly logged?