Repository navigation
fix(sentry): restore server error reporting #511
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
Producdevity
merged 10 commits into
staging
from
fix/purchase-verification-and-monitoring
Oct 31, 2026
Merged
Changes from all commits
Commits
Show all changes
10 commits
Select commit
Hold shift + click to select a range
fe1dae8
fix: restore server error reporting
Producdevity 9184240
fix: label Sentry releases and pin browser CI runner
Producdevity 439d7dc
fix: disambiguate browser checks and preserve Sentry release fallback
Producdevity 7e968d0
test: wait for failed games request before checking page shell
Producdevity dbad987
fix: load server instrumentation from src and preserve error causes
Producdevity 77f3b8a
fix: keep startup responsive and preserve server diagnostics
Producdevity 5d97182
test: wait for report table before checking accessibility
Producdevity b338e80
fix: share catalog loads during startup and concurrent lookups
Producdevity 5292700
test: verify catalog outage recovery and tRPC route reporting
Producdevity 56b01c0
fix: isolate catalog refreshes and bound shared downloads
Producdevity File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,21 +1,14 @@ | ||
| // This file configures the initialization of Sentry on the server. | ||
| // The config you add here will be used whenever the server handles a request. | ||
| // https://docs.sentry.io/platforms/javascript/guides/nextjs/ | ||
|
|
||
| import * as Sentry from '@sentry/nextjs' | ||
| import { env } from '@/lib/env' | ||
|
|
||
| // Only enable Sentry when explicitly configured for this deployment. | ||
| if (process.env.NEXT_PUBLIC_ENABLE_SENTRY === 'true') { | ||
| Sentry.init({ | ||
| dsn: 'https://85ca585e45005d8786e361c3456518bf@o74828.ingest.us.sentry.io/4509717207318529', | ||
|
|
||
| // Define how likely traces are sampled. Adjust this value in production, or use tracesSampler for greater control. | ||
| tracesSampleRate: 1, | ||
|
|
||
| // Enable logs to be sent to Sentry | ||
| environment: env.APP_ENV, | ||
| ...(process.env.APP_VERSION ? { release: process.env.APP_VERSION } : {}), | ||
| sampleRate: 1, | ||
| tracesSampleRate: 0.1, | ||
| enableLogs: true, | ||
|
|
||
| // Setting this option to true will print useful information to the console while you're setting up Sentry. | ||
| debug: false, | ||
| sendDefaultPii: false, | ||
| }) | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,70 @@ | ||
| import { afterEach, describe, expect, it, vi } from 'vitest' | ||
|
|
||
| const mocks = vi.hoisted(() => ({ | ||
| init: vi.fn(), | ||
| captureRequestError: vi.fn(), | ||
| initializeServerOnce: vi.fn(), | ||
| })) | ||
|
|
||
| vi.mock('@sentry/nextjs', () => ({ | ||
| init: mocks.init, | ||
| captureRequestError: mocks.captureRequestError, | ||
| })) | ||
| vi.mock('./server/init', () => ({ initializeServerOnce: mocks.initializeServerOnce })) | ||
|
|
||
| afterEach(() => { | ||
| vi.unstubAllEnvs() | ||
| vi.resetModules() | ||
| vi.clearAllMocks() | ||
| }) | ||
|
|
||
| async function loadInstrumentation(runtime: string, enabled = true) { | ||
| vi.resetModules() | ||
| vi.stubEnv('NEXT_RUNTIME', runtime) | ||
| vi.stubEnv('NEXT_PUBLIC_ENABLE_SENTRY', String(enabled)) | ||
| vi.stubEnv('NEXT_PHASE', '') | ||
| return import('./instrumentation') | ||
| } | ||
|
|
||
| describe('server instrumentation entry point', () => { | ||
| it('initializes Sentry before starting Node server services', async () => { | ||
| const instrumentation = await loadInstrumentation('nodejs') | ||
| await instrumentation.register() | ||
|
|
||
| expect(mocks.init).toHaveBeenCalledTimes(1) | ||
| expect(mocks.initializeServerOnce).toHaveBeenCalledTimes(1) | ||
| expect(mocks.init.mock.invocationCallOrder[0]).toBeLessThan( | ||
| mocks.initializeServerOnce.mock.invocationCallOrder[0] ?? 0, | ||
| ) | ||
| }) | ||
|
|
||
| it('does not initialize Node services in an unsupported runtime', async () => { | ||
| const instrumentation = await loadInstrumentation('edge') | ||
| await instrumentation.register() | ||
|
|
||
| expect(mocks.init).not.toHaveBeenCalled() | ||
| expect(mocks.initializeServerOnce).not.toHaveBeenCalled() | ||
| }) | ||
|
|
||
| it('starts services with Sentry disabled', async () => { | ||
| const instrumentation = await loadInstrumentation('nodejs', false) | ||
| await instrumentation.register() | ||
|
|
||
| expect(mocks.init).not.toHaveBeenCalled() | ||
| expect(mocks.initializeServerOnce).toHaveBeenCalledTimes(1) | ||
| }) | ||
|
|
||
| it('skips runtime initialization during the production build', async () => { | ||
| const instrumentation = await loadInstrumentation('nodejs') | ||
| vi.stubEnv('NEXT_PHASE', 'phase-production-build') | ||
| await instrumentation.register() | ||
|
|
||
| expect(mocks.init).not.toHaveBeenCalled() | ||
| expect(mocks.initializeServerOnce).not.toHaveBeenCalled() | ||
| }) | ||
|
|
||
| it('exports the Sentry server-request error handler', async () => { | ||
| const instrumentation = await loadInstrumentation('nodejs') | ||
| expect(instrumentation).toHaveProperty('onRequestError', mocks.captureRequestError) | ||
| }) | ||
| }) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,7 +1,8 @@ | ||
| import { APP_ERROR_CODES } from './errors' | ||
|
|
||
| export function getSerializableAppError(cause: unknown): Record<string, unknown> | null { | ||
| if (!cause || typeof cause !== 'object') return null | ||
| if (!cause || typeof cause !== 'object' || !('code' in cause)) return null | ||
|
|
||
| const payload = cause as Record<string, unknown> | ||
| // tRPC wraps `cause` in an Error and superjson strips custom props off Errors; copy to a plain object. | ||
| return typeof payload.code === 'string' ? { ...payload } : null | ||
| return Object.values(APP_ERROR_CODES).some((code) => code === cause.code) ? { ...cause } : null | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.