import * as Sentry from '@sentry/nextjs';
console.log('Initializing Sentry Client Config for Next.js');
Sentry.init({
// Use the actual DSN for the project experiencing the issue
dsn: "(Note: Actual DSN redacted for public issue),
// Enable debug logging to see SDK internal messages
debug: true,
// Ensure performance monitoring is enabled if comparing with traces
tracesSampleRate: 1.0,
// Specify environment (optional but good practice)
environment: 'development',
// Optional: Specify release
// release: 'my-test-release@1.0.0',
// Other integrations like Replay might be active, but start minimal for repro
// integrations: [],
});
console.log('Sentry client config init completed.');
// File: src/app/sentry-test/page.js (or similar route in App Router)
'use client'; // Required for button interaction
import React from 'react';
import * as Sentry from '@sentry/nextjs';
export default function SentryTestPage() {
const triggerError = () => {
try {
// Create a unique error instance
const testError = new Error("Manual captureException Test Error - " + new Date().toISOString());
console.log("[Test Page] Reporting error to Sentry:", testError);
// Capture the exception using the SDK
const eventId = Sentry.captureException(testError);
console.log("[Test Page] Sentry.captureException called. Event ID:", eventId); // Critical log
// Attempt to flush events (also completes successfully in tests)
Sentry.flush(2000).then(() => {
console.log('[Test Page] Sentry.flush completed.'); // Critical log
}).catch(err => {
console.error('[Test Page] Sentry.flush failed:', err);
});
} catch (error) {
console.error("[Test Page] Failed to call Sentry.captureException:", error);
}
};
return (
<div style={{ padding: '20px' }}>
<h1>Sentry Test Page (Next.js App Router)</h1>
<button
onClick={triggerError}
style={{ padding: '10px', backgroundColor: 'red', color: 'white', border: 'none' }}
>
Trigger Test Error via captureException
</button>
<p style={{ marginTop: '1em' }}>Check browser console and network tab after clicking.</p>
</div>
);
}
Is there an existing issue for this?
How do you use Sentry?
Sentry Saas (sentry.io)
Which SDK are you using?
@sentry/nextjs
SDK Version
9.9.0
Framework Version
14.0.4
Link to Sentry event
No response
Reproduction Example/SDK Setup
Steps to Reproduce
Expected Result
Actual Result
Additional Context / Key Findings from Troubleshooting:
Performance Monitoring Traces are successfully sent from the same application and appear correctly in the Sentry Traces UI.
Testing connectivity via curl from the command line on the same machine to the project's Sentry ingest endpoint succeeds (curl ... https://@/api//envelope/... returns 200 OK or 4xx).
System-level interference (browser extensions, hosts file, Windows Firewall, proxy settings) have been investigated and seem unlikely to be the cause.
A Barebones HTML Test using the Sentry CDN bundle (@sentry/browser) directly in an HTML file (loaded via file:///) works correctly: it generates an Event ID, the network request appears in DevTools with a 200 OK status, and the event appears in the Sentry Issues UI. This suggests the issue is specific to the @sentry/nextjs integration or its interaction within the Next.js environment.