Skip to content

Improve Sentry react router steps #17228

Closed

Description

@jbojcic1

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.

Activity

  1. linear commented on Jul 30, 2025

    @linear
  2. moved this to Waiting for: Product Owner in GitHub Issues with 👀 3on Jul 30, 2025
  3. self-assigned this
    on Jul 30, 2025
  4. chargome commented on Jul 30, 2025

    @chargome
    Member

    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!

  5. moved this from Waiting for: Product Owner to No status in GitHub Issues with 👀 3on Jul 30, 2025
  6. jbojcic1 commented on Jul 30, 2025

    @jbojcic1
    Author

    I'll try to bake this into the SDK directly

    great. That sounds even better

  7. moved this to Waiting for: Product Owner in GitHub Issues with 👀 3on Jul 30, 2025
  8. github-actions commented on Jul 31, 2025

    @github-actions
    Contributor

    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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

Projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions