Skip to content

ref(remix): Use debug instead of logger #16988

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
merged 1 commit into from
Jul 15, 2025
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
4 changes: 2 additions & 2 deletions packages/remix/src/client/index.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { logger } from '@sentry/core';
import { debug } from '@sentry/core';
import { DEBUG_BUILD } from '../utils/debug-build';

export * from '@sentry/react';
Expand All @@ -17,7 +17,7 @@ export { browserTracingIntegration } from './browserTracingIntegration';
*/
export async function captureRemixServerException(err: unknown, name: string, request: Request): Promise<void> {
DEBUG_BUILD &&
logger.warn(
debug.warn(
'`captureRemixServerException` is a server-only function and should not be called in the browser. ' +
'This function is a no-op in the browser environment.',
);
Expand Down
4 changes: 2 additions & 2 deletions packages/remix/src/client/performance.tsx
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
import type { Client, StartSpanOptions } from '@sentry/core';
import {
debug,
getActiveSpan,
getCurrentScope,
getRootSpan,
isNodeEnv,
logger,
SEMANTIC_ATTRIBUTE_SENTRY_ORIGIN,
SEMANTIC_ATTRIBUTE_SENTRY_SOURCE,
} from '@sentry/core';
Expand Down Expand Up @@ -119,7 +119,7 @@ export function withSentry<P extends Record<string, unknown>, R extends React.Co
if (!_useEffect || !_useLocation || !_useMatches) {
DEBUG_BUILD &&
!isNodeEnv() &&
logger.warn('Remix SDK was unable to wrap your root because of one or more missing parameters.');
debug.warn('Remix SDK was unable to wrap your root because of one or more missing parameters.');

// @ts-expect-error Setting more specific React Component typing for `R` generic above
// will break advanced type inference done by react router params
Expand Down
6 changes: 3 additions & 3 deletions packages/remix/src/server/errors.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,9 @@ import type { RequestEventData, Span } from '@sentry/core';
import {
addExceptionMechanism,
captureException,
debug,
getClient,
handleCallbackErrors,
logger,
objectify,
winterCGRequestToRequestData,
} from '@sentry/core';
Expand Down Expand Up @@ -46,7 +46,7 @@ export async function captureRemixServerException(err: unknown, name: string, re
// Skip capturing if the request is aborted as Remix docs suggest
// Ref: https://remix.run/docs/en/main/file-conventions/entry.server#handleerror
if (request.signal.aborted) {
DEBUG_BUILD && logger.warn('Skipping capture of aborted request');
DEBUG_BUILD && debug.warn('Skipping capture of aborted request');
return;
}

Expand All @@ -55,7 +55,7 @@ export async function captureRemixServerException(err: unknown, name: string, re
try {
normalizedRequest = winterCGRequestToRequestData(request);
} catch (e) {
DEBUG_BUILD && logger.warn('Failed to normalize Remix request');
DEBUG_BUILD && debug.warn('Failed to normalize Remix request');
}

const objectifiedErr = objectify(err);
Expand Down
12 changes: 6 additions & 6 deletions packages/remix/src/server/instrumentServer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ import type {
import type { RequestEventData, Span, TransactionSource, WrappedFunction } from '@sentry/core';
import {
continueTrace,
debug,
fill,
getActiveSpan,
getClient,
Expand All @@ -24,7 +25,6 @@ import {
hasSpansEnabled,
isNodeEnv,
loadModule,
logger,
SEMANTIC_ATTRIBUTE_SENTRY_OP,
SEMANTIC_ATTRIBUTE_SENTRY_ORIGIN,
SEMANTIC_ATTRIBUTE_SENTRY_SOURCE,
Expand Down Expand Up @@ -73,7 +73,7 @@ export function sentryHandleError(err: unknown, { request }: DataFunctionArgs):
}

captureRemixServerException(err, 'remix.server.handleError', request).then(null, e => {
DEBUG_BUILD && logger.warn('Failed to capture Remix Server exception.', e);
DEBUG_BUILD && debug.warn('Failed to capture Remix Server exception.', e);
});
}

Expand Down Expand Up @@ -220,7 +220,7 @@ function makeWrappedRootLoader() {
// We skip injection of trace and baggage in those cases.
// For `redirect`, a valid internal redirection target will have the trace and baggage injected.
if (isRedirectResponse(res) || isCatchResponse(res)) {
DEBUG_BUILD && logger.warn('Skipping injection of trace and baggage as the response does not have a body');
DEBUG_BUILD && debug.warn('Skipping injection of trace and baggage as the response does not have a body');
return res;
} else {
const data = await extractData(res);
Expand All @@ -235,7 +235,7 @@ function makeWrappedRootLoader() {
},
);
} else {
DEBUG_BUILD && logger.warn('Skipping injection of trace and baggage as the response body is not an object');
DEBUG_BUILD && debug.warn('Skipping injection of trace and baggage as the response body is not an object');
return res;
}
}
Expand Down Expand Up @@ -289,7 +289,7 @@ function wrapRequestHandler<T extends ServerBuild | (() => ServerBuild | Promise
try {
normalizedRequest = winterCGRequestToRequestData(request);
} catch (e) {
DEBUG_BUILD && logger.warn('Failed to normalize Remix request');
DEBUG_BUILD && debug.warn('Failed to normalize Remix request');
}

if (options?.instrumentTracing && resolvedRoutes) {
Expand Down Expand Up @@ -447,7 +447,7 @@ export function instrumentServer(options?: { instrumentTracing?: boolean }): voi
}>('@remix-run/server-runtime', module);

if (!pkg) {
DEBUG_BUILD && logger.warn('Remix SDK was unable to require `@remix-run/server-runtime` package.');
DEBUG_BUILD && debug.warn('Remix SDK was unable to require `@remix-run/server-runtime` package.');

return;
}
Expand Down
4 changes: 2 additions & 2 deletions packages/remix/src/server/sdk.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import type { Integration } from '@sentry/core';
import { applySdkMetadata, logger } from '@sentry/core';
import { applySdkMetadata, debug } from '@sentry/core';
import type { NodeClient, NodeOptions } from '@sentry/node';
import { getDefaultIntegrations as getDefaultNodeIntegrations, init as nodeInit, isInitialized } from '@sentry/node';
import { DEBUG_BUILD } from '../utils/debug-build';
Expand All @@ -26,7 +26,7 @@ export function init(options: RemixOptions): NodeClient | undefined {
applySdkMetadata(options, 'remix', ['remix', 'node']);

if (isInitialized()) {
DEBUG_BUILD && logger.log('SDK already initialized');
DEBUG_BUILD && debug.log('SDK already initialized');

return;
}
Expand Down
4 changes: 2 additions & 2 deletions packages/remix/src/utils/utils.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import type { ActionFunctionArgs, LoaderFunctionArgs, ServerBuild } from '@remix-run/node';
import type { AgnosticRouteObject } from '@remix-run/router';
import type { Span, TransactionSource } from '@sentry/core';
import { logger } from '@sentry/core';
import { debug } from '@sentry/core';
import { DEBUG_BUILD } from './debug-build';
import { getRequestMatch, matchServerRoutes } from './vendor/response';

Expand Down Expand Up @@ -39,7 +39,7 @@ export async function storeFormDataKeys(
}
});
} catch (e) {
DEBUG_BUILD && logger.warn('Failed to read FormData from request', e);
DEBUG_BUILD && debug.warn('Failed to read FormData from request', e);
}
}

Expand Down
6 changes: 3 additions & 3 deletions packages/remix/test/integration/test/server/utils/helpers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import * as http from 'http';
import { AddressInfo } from 'net';
import * as path from 'path';
import { createRequestHandler } from '@remix-run/express';
import { logger } from '@sentry/core';
import { debug } from '@sentry/core';
import type { EnvelopeItemType, Event, TransactionEvent } from '@sentry/core';
/* eslint-disable @typescript-eslint/no-unsafe-member-access */
import * as Sentry from '@sentry/node';
Expand Down Expand Up @@ -46,7 +46,7 @@ async function makeRequest(
} catch (e) {
// We sometimes expect the request to fail, but not the test.
// So, we do nothing.
logger.warn(e);
debug.warn(e);
}
}

Expand Down Expand Up @@ -195,7 +195,7 @@ class TestEnv {

this._closeServer()
.catch(e => {
logger.warn(e);
debug.warn(e);
})
.finally(() => {
resolve(envelopes);
Expand Down
Loading