-
-
Notifications
You must be signed in to change notification settings - Fork 1.7k
feat(tanstackstart-react): Add sentryTanstackStart Vite plugin for Source Map Uploads #18712
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
base: develop
Are you sure you want to change the base?
Conversation
node-overhead report 🧳Note: This is a synthetic benchmark with a minimal express app and does not necessarily reflect the real-world performance impact in an application.
|
| /** | ||
| * Build options for the Sentry plugin. These options are used during build-time by the Sentry SDK. | ||
| */ | ||
| export type SentryTanstackStartReactPluginOptions = { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You can/should extend from this type, so we can make sure that all build-time options are aligned:
| export interface BuildTimeOptionsBase { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ah nice thanks I did not know that existed, updated
| if (process.env.NODE_ENV !== 'development') { | ||
| // Check if source maps upload is enabled | ||
| // Default to enabled | ||
| const sourceMapsEnabled = options.sourceMapsUploadOptions?.enabled ?? true; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You probably want to use options.sourcemaps.disable here. Also make sure people can still create a release, even if they don't want to upload source maps.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
updated to use disable
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
also always adding the sentry vite plugin down passing down the source maps disable option so that release creation works also if people do not use source maps
|
A general thought I had on this: Are the sources included in Nitro source maps? In the Nuxt SDK, we have to disable this setting:
|
Lms24
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Naive question for now: What's the advantage over this wrapper that we can't achieve with just exporting a plugin? If we need to modify the vite config, Vite offers plugin hooks to do so from within a plugin.
I'd personally prefer the plugin approach because this is a pattern that users are more used to than wrapping their config. If you or anyone else has different opinions, let's hear it :D
|
@Lms24 good call, changed the approach from a wrapper to a simple plugin that users can add |
| // Default to auto-deleting source maps from hidden directories after upload | ||
| // Users can override this by explicitly setting sourcemaps.filesToDeleteAfterUpload | ||
| const defaultFilesToDelete = ['.*/**/*.map']; | ||
| const filesToDeleteAfterUpload = sourcemaps?.filesToDeleteAfterUpload ?? defaultFilesToDelete; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Bug: Source maps are deleted unexpectedly because filesToDeleteAfterUpload is defaulted even when uploads are disabled or when build.sourcemap is explicitly configured by the user.
Severity: HIGH
Suggested Fix
Before defaulting filesToDeleteAfterUpload to ['.*/**/*.map'], add a condition to check that source map uploads are not disabled and that the user has not already configured config.build.sourcemap. This will prevent file deletion when uploads are disabled or when the user has explicitly enabled source maps, aligning the behavior with other Sentry SDKs.
Prompt for AI Agent
Review the code at the location below. A potential bug has been identified by an AI
agent.
Verify if this is a real issue. If it is, propose a fix; if not, explain why it's not
valid.
Location: packages/tanstackstart-react/src/vite/sourceMaps.ts#L43-L46
Potential issue: The logic to add the Sentry Vite plugin unconditionally sets a default
value for `filesToDeleteAfterUpload`. This causes two incorrect behaviors. First, if a
user disables source map uploads via `sourcemaps: { disable: true }`, their source map
files will still be deleted from the build output. Second, if a user explicitly enables
source maps in their Vite config (e.g., `build: { sourcemap: true }`), their source maps
will also be deleted, which contradicts the documented intention to preserve user
settings and avoid default actions like deletion in this case. This behavior is
inconsistent with other Sentry SDKs like SolidStart, which correctly check if source
maps are enabled before applying a default deletion configuration.
Did we get this right? 👍 / 👎 to inform future reviews.
Adds sentryTanstackStart Vite plugin to enable automatic source map uploads in TanStack Start applications.
What it does
I tried to align with what we do in other SDKs (e.g. SvelteKit). On a high-level it:
Usage
Tests
Closes #18664