-
-
Notifications
You must be signed in to change notification settings - Fork 1.7k
Description
Problem Statement
React router steps should mention that when running on serverless (Vercel in my case), server might not be able to flush the logs before execution is stopped. Way to mitigate that is to use waitUntil from Vercel (or something similar for other serverless platforms) similarly how it is already used in other Sentry libs like here for next.js where vercelWaitUntil is used.
I spent a lot of time to figure this out so having it mentioned in docs would save people a lot of time. I ended up solving it like this:
import { vercelWaitUntil } from '@sentry/core';
...
export const handleError: HandleErrorFunction = async (error, { request }) => {
// React Router may abort some interrupted requests, don't log those
if (!request.signal.aborted) {
Sentry.captureException(error);
console.error(error);
vercelWaitUntil(flushSafelyWithTimeout());
}
};
also the docs should mention that if you are instrumenting server with import in server entry file (when you are using serverless where you can't use NODE_OPTIONS), vite will tree shake that file so you need to mark it as side effect in package.json
Solution Brainstorm
See problem statement.
Metadata
Metadata
Assignees
Labels
Projects
Status