Skip to content
Open
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
2 changes: 1 addition & 1 deletion .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -810,7 +810,7 @@ jobs:
needs: [job_get_metadata, job_build]
if: needs.job_build.outputs.changed_remix == 'true' || github.event_name != 'pull_request'
runs-on: ubuntu-24.04
timeout-minutes: 10
timeout-minutes: 15
Copy link
Member

Choose a reason for hiding this comment

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

Why did this increase so much?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

After adding the new tests, some of them started randomly timing out slightly above the 10-minute threshold on CI. It can be 11-12. I just increased this much to be ready for when we add more tests.

strategy:
fail-fast: false
matrix:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { waitForTransaction } from '@sentry-internal/test-utils';

test('Sends a pageload transaction to Sentry', async ({ page }) => {
const transactionPromise = waitForTransaction('create-remix-app-express-vite-dev', transactionEvent => {
return transactionEvent.contexts?.trace?.op === 'pageload' && transactionEvent.transaction === 'routes/_index';
return transactionEvent.contexts?.trace?.op === 'pageload' && transactionEvent.transaction === '/';
});

await page.goto('/');
Expand All @@ -15,7 +15,7 @@ test('Sends a pageload transaction to Sentry', async ({ page }) => {

test('Sends a navigation transaction to Sentry', async ({ page }) => {
const transactionPromise = waitForTransaction('create-remix-app-express-vite-dev', transactionEvent => {
return transactionEvent.contexts?.trace?.op === 'navigation' && transactionEvent.transaction === 'routes/user.$id';
return transactionEvent.contexts?.trace?.op === 'navigation' && transactionEvent.transaction === '/user/:id';
});

await page.goto('/');
Expand All @@ -28,6 +28,22 @@ test('Sends a navigation transaction to Sentry', async ({ page }) => {
expect(transactionEvent).toBeDefined();
});

test('Sends a navigation transaction with parameterized route to Sentry', async ({ page }) => {
const transactionPromise = waitForTransaction('create-remix-app-express-vite-dev', transactionEvent => {
return transactionEvent.contexts?.trace?.op === 'navigation';
});

await page.goto('/');

const linkElement = page.locator('id=navigation');
await linkElement.click();

const transactionEvent = await transactionPromise;

expect(transactionEvent).toBeDefined();
expect(transactionEvent.transaction).toBeTruthy();
});

test('Renders `sentry-trace` and `baggage` meta tags for the root route', async ({ page }) => {
await page.goto('/');

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ test('Sends two linked transactions (server & client) to Sentry', async ({ page
const pageLoadParentSpanId = pageloadTransaction.contexts?.trace?.parent_span_id;

expect(httpServerTransaction.transaction).toBe('GET http://localhost:3030/');
expect(pageloadTransaction.transaction).toBe('routes/_index');
expect(pageloadTransaction.transaction).toBe('/');

expect(httpServerTraceId).toBeDefined();
expect(httpServerSpanId).toBeDefined();
Expand Down
Original file line number Diff line number Diff line change
@@ -1,14 +1,15 @@
import { installGlobals } from '@remix-run/node';
import { vitePlugin as remix } from '@remix-run/dev';
import { sentryRemixVitePlugin } from '@sentry/remix';
import { defineConfig } from 'vite';
import tsconfigPaths from 'vite-tsconfig-paths';

import { installGlobals } from '@remix-run/node';

installGlobals();

export default defineConfig({
plugins: [
remix(),
sentryRemixVitePlugin(),
tsconfigPaths({
// The dev server config errors are not relevant to this test app
// https://github.com/aleclarson/vite-tsconfig-paths?tab=readme-ov-file#options
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { waitForTransaction } from '@sentry-internal/test-utils';

test('Sends a pageload transaction to Sentry', async ({ page }) => {
const transactionPromise = waitForTransaction('create-remix-app-express', transactionEvent => {
return transactionEvent.contexts?.trace?.op === 'pageload' && transactionEvent.transaction === 'routes/_index';
return transactionEvent.contexts?.trace?.op === 'pageload' && transactionEvent.transaction === '/';
});

await page.goto('/');
Expand All @@ -15,7 +15,7 @@ test('Sends a pageload transaction to Sentry', async ({ page }) => {

test('Sends a navigation transaction to Sentry', async ({ page }) => {
const transactionPromise = waitForTransaction('create-remix-app-express', transactionEvent => {
return transactionEvent.contexts?.trace?.op === 'navigation' && transactionEvent.transaction === 'routes/user.$id';
return transactionEvent.contexts?.trace?.op === 'navigation' && transactionEvent.transaction === '/user/:id';
});

await page.goto('/');
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ test('Propagates trace when ErrorBoundary is triggered', async ({ page }) => {
const pageLoadParentSpanId = pageloadTransaction.contexts?.trace?.parent_span_id;

expect(httpServerTransaction.transaction).toBe('GET client-error');
expect(pageloadTransaction.transaction).toBe('routes/client-error');
expect(pageloadTransaction.transaction).toBe('/client-error');

expect(httpServerTraceId).toBeDefined();
expect(httpServerSpanId).toBeDefined();
Expand Down Expand Up @@ -132,7 +132,7 @@ test('Sends two linked transactions (server & client) to Sentry', async ({ page
const pageLoadParentSpanId = pageloadTransaction.contexts?.trace?.parent_span_id;

expect(httpServerTransaction.transaction).toBe('GET http://localhost:3030/');
expect(pageloadTransaction.transaction).toBe('routes/_index');
expect(pageloadTransaction.transaction).toBe('/');

expect(httpServerTraceId).toBeDefined();
expect(httpServerSpanId).toBeDefined();
Expand Down
Original file line number Diff line number Diff line change
@@ -1,14 +1,15 @@
import { installGlobals } from '@remix-run/node';
import { vitePlugin as remix } from '@remix-run/dev';
import { sentryRemixVitePlugin } from '@sentry/remix';
import { defineConfig } from 'vite';
import tsconfigPaths from 'vite-tsconfig-paths';

import { installGlobals } from '@remix-run/node';

installGlobals();

export default defineConfig({
plugins: [
remix(),
sentryRemixVitePlugin(),
tsconfigPaths({
// The dev server config errors are not relevant to this test app
// https://github.com/aleclarson/vite-tsconfig-paths?tab=readme-ov-file#options
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
/** @type {import('eslint').Linter.Config} */
module.exports = {
extends: ['@remix-run/eslint-config', '@remix-run/eslint-config/node'],
};
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
node_modules

/.cache
/build
/public/build
.env
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
@sentry:registry=http://127.0.0.1:4873
@sentry-internal:registry=http://127.0.0.1:4873
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
/**
* By default, Remix will handle hydrating your app on the client for you.
* You are free to delete this file if you'd like to, but if you ever want it revealed again, you can run `npx remix reveal` ✨
* For more information, see https://remix.run/file-conventions/entry.client
*/

// Extend the Window interface to include ENV
declare global {
interface Window {
ENV: {
SENTRY_DSN: string;
[key: string]: unknown;
};
}
}

import { RemixBrowser, useLocation, useMatches } from '@remix-run/react';
import * as Sentry from '@sentry/remix';
import { StrictMode, startTransition, useEffect } from 'react';
import { hydrateRoot } from 'react-dom/client';

Sentry.init({
environment: 'qa', // dynamic sampling bias to keep transactions
dsn: window.ENV.SENTRY_DSN,
integrations: [
Sentry.browserTracingIntegration({
useEffect,
useLocation,
useMatches,
}),
Sentry.replayIntegration(),
],
// Performance Monitoring
tracesSampleRate: 1.0, // Capture 100% of the transactions, reduce in production!
// Session Replay
replaysSessionSampleRate: 0.1, // This sets the sample rate at 10%. You may want to change it to 100% while in development and then sample at a lower rate in production.
replaysOnErrorSampleRate: 1.0, // If you're not already sampling the entire session, change the sample rate to 100% when sampling sessions where errors occur.
tunnel: 'http://localhost:3032/', // proxy server
});

startTransition(() => {
hydrateRoot(
document,
<StrictMode>
<RemixBrowser />
</StrictMode>,
);
});
Original file line number Diff line number Diff line change
@@ -0,0 +1,136 @@
/**
* By default, Remix will handle generating the HTTP Response for you.
* You are free to delete this file if you'd like to, but if you ever want it revealed again, you can run `npx remix reveal` ✨
* For more information, see https://remix.run/file-conventions/entry.server
*/

import { PassThrough } from 'node:stream';

import type { AppLoadContext, EntryContext } from '@remix-run/node';
import { createReadableStreamFromReadable } from '@remix-run/node';
import { installGlobals } from '@remix-run/node';
import { RemixServer } from '@remix-run/react';
import isbot from 'isbot';
import { renderToPipeableStream } from 'react-dom/server';
import * as Sentry from '@sentry/remix';

installGlobals();

const ABORT_DELAY = 5_000;

Sentry.init({
environment: 'qa', // dynamic sampling bias to keep transactions
dsn: process.env.E2E_TEST_DSN,
tunnel: 'http://localhost:3031/', // proxy server
tracesSampleRate: 1.0, // Capture 100% of the transactions, reduce in production!
});
Copy link

Choose a reason for hiding this comment

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

Bug: Duplicate Sentry Initialization Causes Configuration Conflicts

There are two Sentry.init() calls in app/entry.server.tsx. The second call overwrites the first, leading to conflicting configurations, specifically the tunnel setting. This results in incorrect SDK initialization.

Fix in Cursor Fix in Web


const handleErrorImpl = () => {
Sentry.setTag('remix-test-tag', 'remix-test-value');
};

export const handleError = Sentry.wrapHandleErrorWithSentry(handleErrorImpl);

export default function handleRequest(
request: Request,
responseStatusCode: number,
responseHeaders: Headers,
remixContext: EntryContext,
loadContext: AppLoadContext,
) {
return isbot(request.headers.get('user-agent'))
? handleBotRequest(request, responseStatusCode, responseHeaders, remixContext)
: handleBrowserRequest(request, responseStatusCode, responseHeaders, remixContext);
}

function handleBotRequest(
request: Request,
responseStatusCode: number,
responseHeaders: Headers,
remixContext: EntryContext,
) {
return new Promise((resolve, reject) => {
let shellRendered = false;
const { pipe, abort } = renderToPipeableStream(
<RemixServer context={remixContext} url={request.url} abortDelay={ABORT_DELAY} />,
{
onAllReady() {
shellRendered = true;
const body = new PassThrough();
const stream = createReadableStreamFromReadable(body);

responseHeaders.set('Content-Type', 'text/html');

resolve(
new Response(stream, {
headers: responseHeaders,
status: responseStatusCode,
}),
);

pipe(body);
},
onShellError(error: unknown) {
reject(error);
},
onError(error: unknown) {
responseStatusCode = 500;
// Log streaming rendering errors from inside the shell. Don't log
// errors encountered during initial shell rendering since they'll
// reject and get logged in handleDocumentRequest.
if (shellRendered) {
console.error(error);
}
},
},
);

setTimeout(abort, ABORT_DELAY);
});
}

function handleBrowserRequest(
request: Request,
responseStatusCode: number,
responseHeaders: Headers,
remixContext: EntryContext,
) {
return new Promise((resolve, reject) => {
let shellRendered = false;
const { pipe, abort } = renderToPipeableStream(
<RemixServer context={remixContext} url={request.url} abortDelay={ABORT_DELAY} />,
{
onShellReady() {
shellRendered = true;
const body = new PassThrough();
const stream = createReadableStreamFromReadable(body);

responseHeaders.set('Content-Type', 'text/html');

resolve(
new Response(stream, {
headers: responseHeaders,
status: responseStatusCode,
}),
);

pipe(body);
},
onShellError(error: unknown) {
reject(error);
},
onError(error: unknown) {
responseStatusCode = 500;
// Log streaming rendering errors from inside the shell. Don't log
// errors encountered during initial shell rendering since they'll
// reject and get logged in handleDocumentRequest.
if (shellRendered) {
console.error(error);
}
},
},
);

setTimeout(abort, ABORT_DELAY);
});
}
Loading