- 
          
- 
                Notifications
    You must be signed in to change notification settings 
- Fork 1.7k
Closed as not planned
Description
Is there an existing issue for this?
- I have checked for existing issues https://github.com/getsentry/sentry-javascript/issues
- I have reviewed the documentation https://docs.sentry.io/
- I am using the latest SDK release https://github.com/getsentry/sentry-javascript/releases
How do you use Sentry?
Sentry Saas (sentry.io)
Which SDK are you using?
@sentry/cloudflare - hono
SDK Version
9.34.0
Framework Version
Hono 4.8.3
Link to Sentry event
No response
Reproduction Example/SDK Setup
// lib/db.ts 
import { env } from "cloudflare:workers";
export const db = Sentry.instrumentD1WithSentry(env.DB);// index.ts
import { Hono } from "hono";
import { db } from "~/lib/db";
type Env = {
	Bindings: CloudflareEnv;
};
const app = new Hono<Env>();
app.get("/", async (c) => {
	const result = await db.exec("SELECT 1");
	
	return c.json({
		message: "Hello Hono!",
		result,
	});
});
export default Sentry.withSentry((env: CloudflareEnv) => {
	return {
		dsn: env.SENTRY_DSN,
		// Adds request headers & IP for users
		sendDefaultPii: true,
		// Enable logs to be sent to Sentry
		_experiments: { enableLogs: true },
		tracesSampleRate: 1.0,
	};
}, app);Steps to Reproduce
- Setup D1 instrumentation as per the docs
- Use that db somewhere in your app
- Deploy the worker
Expected Result
Without the instrumentation, it works fine both locally & in production.
With the instrumentation, it works locally, but the deployment fails due to env.DB being undefined.
I would expect the behavior to be consistent with the non-instrumented version.
Actual Result
CloudflareApiError: Error 400 uploading worker script worker 'backend': Uncaught TypeError: Cannot read properties of undefined (reading 'prepare')
  at worker.js:59795:31 in instrumentD1WithSentry
Metadata
Metadata
Assignees
Projects
Status
Waiting for: Community