Skip to content

feat(tanstackstart-react): Trace server functions #18513

@github-actions

Description

@github-actions

Note

The pull request "feat(tanstackstart-react): Trace server functions" was created by @nicohrubec but did not reference an issue. Therefore this issue was created for better visibility in external tools like Linear.

This PR adds tracing for tss server functions. To achieve this I added a new withSentry wrapper that can be used to instrument the tss server entry point:

import { withSentry } from '@sentry/tanstackstart-react';

import handler, { createServerEntry } from '@tanstack/react-start/server-entry';

const requestHandler = withSentry({
  fetch(request: Request) {
    return handler.fetch(request);
  },
});

export default createServerEntry(requestHandler);

With this we get spans for server functions executed via fetch calls to the server. A limitation of this approach is that out-of-the-box this will only start a single span for the initial request made to the server. So for instance if a server function calls another server function, we will still only get a single span for the outer server function and users would need to wrap the inner call manually.

Screenshot from my sample app with the current state:
Screenshot 2025-12-15 at 15 22 40

Tests added:

  • Basic transaction test to verify that we get spans if a server function is executed.
  • Another transaction test documenting that users need to manually wrap "nested" server functions.

Metadata

Metadata

Assignees

Labels

No labels
No labels

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions