Skip to content
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

Add server stderr logging #1203

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
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
27 changes: 25 additions & 2 deletions apps/cyberstorm-remix/app/entry.server.tsx
Original file line number Diff line number Diff line change
@@ -1,12 +1,18 @@
import { PassThrough } from "node:stream";

import type { AppLoadContext, EntryContext } from "@remix-run/node";
import type {
ActionFunctionArgs,
AppLoadContext,
EntryContext,
LoaderFunctionArgs,
} from "@remix-run/node";
import { createReadableStreamFromReadable } from "@remix-run/node";
import { RemixServer } from "@remix-run/react";
import * as isbotModule from "isbot";
import { renderToPipeableStream } from "react-dom/server";

import * as Sentry from "@sentry/remix";
import { DataFunctionArgs } from "node_modules/@sentry/remix/types/utils/vendor/types";

Sentry.init({
dsn: process.env.SENTRY_DSN,
Expand Down Expand Up @@ -165,4 +171,21 @@ function handleBrowserRequest(
});
}

export const handleError = Sentry.sentryHandleError;
export const handleError = (
err: unknown | object,
{ request }: LoaderFunctionArgs | ActionFunctionArgs
) => {
const message =
err instanceof Object && "message" in err && err.message
? err.message
: "No message";
const stack =
err instanceof Object && "stack" in err && err.stack
? err.stack
: "No stack";
process.stderr.write(
`Error: ${err}\nError message: ${message}\nError stack: ${stack}\n`
);
const remixRequest = { request } as DataFunctionArgs;
Sentry.sentryHandleError(err, remixRequest);
};
Loading