Skip to content
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

@sentry/cloudflare not sending debugIds ? #14841

Open
6 of 8 tasks
bhanuka-yd opened this issue Dec 27, 2024 · 3 comments
Open
6 of 8 tasks

@sentry/cloudflare not sending debugIds ? #14841

bhanuka-yd opened this issue Dec 27, 2024 · 3 comments
Labels
Package: cloudflare Issues related to the Sentry Cloudflare Workers SDK Waiting for: Community

Comments

@bhanuka-yd
Copy link

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

@getsantry getsantry bot moved this to Waiting for: Product Owner in GitHub Issues with 👀 3 Dec 27, 2024
@github-actions github-actions bot added the Package: cloudflare Issues related to the Sentry Cloudflare Workers SDK label Dec 27, 2024
@andreiborza
Copy link
Member

Hi @bhanuka-yd, thanks for writing in.

Could you please set debug: true in the rollup plugin and paste some build logs?

@bhanuka-yd
Copy link
Author

bhanuka-yd commented Dec 27, 2024

Hi @andreiborza, sure here's the output.

rollup -c rollup.config.mjs

[sentry-rollup-plugin] Info: Using environment variables configured in ".env.sentry-build-plugin".

src/index.ts → dist/worker.js...
[sentry-rollup-plugin] Info: Sending telemetry data on issues and performance to Sentry. To disable telemetry, set options.telemetry to false.
[sentry-rollup-plugin] Debug: No sourcemaps.assets option provided, falling back to uploading detected build artifacts.

Found 2 files
Analyzing 2 sources
Analyzing completed in 0.032s
Adding source map references
Bundling completed in 0.19s
Bundled 2 files for upload
Bundle ID: 759fb507-c679-513f-8436-8fcd080c42ea
Optimizing completed in 0.006s
Uploading completed in 4.478s
Uploaded files to Sentry
Processing completed in 1.459s
File upload complete (processing pending on server)
Organization: ------------
Project: ---------------
Release: 69e8d6aa31b6a806ea9388d59583069411fbf4d3
Dist: None
Upload type: artifact bundle

Source Map Upload Report
Scripts
~/167414e4-08a0-4d95-a51f-9efdaa05e16a-0.js (sourcemap at worker.js.map, debug id 167414e4-08a0-4d95-a51f-9efdaa05e16a)
Source Maps
~/167414e4-08a0-4d95-a51f-9efdaa05e16a-0.js.map (debug id 167414e4-08a0-4d95-a51f-9efdaa05e16a)
[sentry-rollup-plugin] Info: Successfully uploaded source maps to Sentry
(!) Circular dependencies
node_modules/@smithy/util-stream/dist-es/blob/Uint8ArrayBlobAdapter.js -> node_modules/@smithy/util-stream/dist-es/blob/transforms.js -> node_modules/@smithy/util-stream/dist-es/blob/Uint8ArrayBlobAdapter.js
node_modules/@aws-crypto/crc32c/build/module/index.js -> node_modules/@aws-crypto/crc32c/build/module/aws_crc32c.js -> node_modules/@aws-crypto/crc32c/build/module/index.js
node_modules/@aws-crypto/crc32/build/module/index.js -> node_modules/@aws-crypto/crc32/build/module/aws_crc32.js -> node_modules/@aws-crypto/crc32/build/module/index.js
...and 7 more
created dist/worker.js in 23.1s
Total Upload: 1716.87 KiB / gzip: 320.36 KiB
Worker Startup Time: 82 ms

@Lms24
Copy link
Member

Lms24 commented Jan 2, 2025

Hi @bhanuka-yd, I didn't find anything yet that would prohibit debug ids from being applied to error events. Before we dig into this deeper: Can you confirm that the files where debug ids were injected correctly are the exact same files that get deployed to cloudflare? The debug_meta field in the event JSON can only be populated, if the deployed files contain the e._sentryDebugIds snippet.

If this is the case, we need to dive deeper into SDK internals to understand what's going on. If you can, please provide a minimal reproduction, for example in the form of a GH repo, zip file or whatever else works for you.

If you can't, please console.log some things:

  • in beforeSend, please log out event and event.exception.values so that we can check what the SDK sends exactly. Sometimes, the event JSON in the Sentry UI already contains slight changes.
  • in beforeSend, please also log out globalThis._sentryDebugIds so that we can check if the SDK could even pick up debug ids.

Side-note: I did find a bug in our debug id application logic but it's rather an edge case, where debug ids were not correctly applied to events containing multiple errors. However I don't think this has anything to do with your problem. Anyway, the found bug will be fixed via #14881.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Package: cloudflare Issues related to the Sentry Cloudflare Workers SDK Waiting for: Community
Projects
Status: Waiting for: Community
Development

No branches or pull requests

3 participants