Skip to content

Add docs and wizard to configure sourcemaps for cloudflare + wrangler #14841

Closed
@bhanuka-yd

Description

@bhanuka-yd

Is there an existing issue for this?

How do you use Sentry?

Sentry Saas (sentry.io)

Which SDK are you using?

@sentry/cloudflare

SDK Version

8.47.0

Framework Version

wrangler: 3.99.0

Link to Sentry event

https://hyperbyte.sentry.io/issues/15388878/events/6faf01ca3f04449081bf9dab43025a33/

Reproduction Example/SDK Setup

index.js

export default Sentry.withSentry(
	(env: Env) => ({
		dsn: env.SENTRY_DSN,
		// Set tracesSampleRate to 1.0 to capture 100% of spans for tracing.
		tracesSampleRate: env.SENTRY_TRACES_SAMPLE_RATE,
		environment: 'production'
	}),
	{
		async fetch(request: Request, env, ctx): Promise<Response> {

			const configParse = configSchema.safeParse(env);
			if (!configParse.success) {
				return configErr(configParse.error, env);
			} else {
				env = configParse.data;
			}

			globalThis.env = env;
			// globalThis.prisma = prismaFactory(env.DATABASE_URL);
			globalThis.db = getDB(env.DATABASE_URL);

			return fetchRequestHandler({
				endpoint: '/trpc',
				req: request,
				router: appRouter,
				createContext
			});
		}
	} satisfies ExportedHandler<Env>
);

error-generating-file.js

Sentry.captureException(result.error);

rollup.config.js

    import resolve from '@rollup/plugin-node-resolve';
    import commonjs from '@rollup/plugin-commonjs';
    import typescript from '@rollup/plugin-typescript';
    import terser from '@rollup/plugin-terser';
    import json from '@rollup/plugin-json';
    import { sentryRollupPlugin } from '@sentry/rollup-plugin';
    
    export default {
    	input: 'src/index.ts',  // Path to your main entry file,
    	output: {
    		file: 'dist/worker.js',  // Output path for your bundled worker
    		format: 'es',  // Cloudflare Workers support ES Modules
    		sourcemap: true,
    		inlineDynamicImports: true
    	},
    	plugins: [
    		resolve(),  // Resolve node modules
    		commonjs(),
    		json(),
    		typescript({
    			tsconfig: './tsconfig.json'
    		}),
    		terser(),   // Minify the output (optional)
    		sentryRollupPlugin({
    			authToken: process.env.SENTRY_AUTH_TOKEN,
    			org: '------',
    			project: '--------'
    		})
    
    	]
    };

wrangler.toml

upload_source_maps = true

[build]
#custom build command
command = "npm run build"

Steps to Reproduce

  1. Add sentry @sentry/cloudflare
  2. Setup init
  3. Test using Sentry.captureException()
  4. Setup rollup

Expected Result

  • Compiled code includes e._sentryDebugIds=e._sentryDebugIds||{}
  • Issue reported to sentry
  • Issue Stack-trace visible
  • Issue Stack-trace un-minified
  • event json does not include debug_meta

Actual Result

  • Compiled code includes e._sentryDebugIds=e._sentryDebugIds||{}
  • Issue reported to sentry
  • Issue Stack-trace visible
  • Issue Stack-trace un-minified
  • event json does not include debug_meta

shows that
Image

i have checked the event json and it does not contain debug_meta

Metadata

Metadata

Assignees

No one assigned

    Projects

    Status

    No status

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions