You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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
Hey @jbojcic1 thanks for putting in the effort to debug this. Good call, but instead of putting this into the docs I'll try to bake this into the SDK directly. Sorry if this caused you trouble!
Activity
linear commentedon Jul 30, 2025
JS-793 Improve Sentry react router steps
chargome commentedon Jul 30, 2025
Hey @jbojcic1 thanks for putting in the effort to debug this. Good call, but instead of putting this into the docs I'll try to bake this into the SDK directly. Sorry if this caused you trouble!
jbojcic1 commentedon Jul 30, 2025
great. That sounds even better
github-actions commentedon Jul 31, 2025
A PR closing this issue has just been released 🚀
This issue was referenced by PR #17235, which was included in the 10.0.0 release.