Mathias Lafeldt
Mathias Lafeldt
@mariusbolik Thanks for the workaround! ```ts const sentry = defineMiddleware(async (context, next) => { return wrapRequestHandler( { options: { dsn: import.meta.env.SENTRY_DSN, environment: import.meta.env.MODE, // tracesSampleRate: 1.0, }, request: context.request, context:...
Ok, it looks like adding something like this does the trick: ```ts if (typeof context.locals.runtime.ctx?.waitUntil !== 'function') { return next() } ```
> Hmm `waitUntil` should always be defined in the cloudflare runtime - let me dig in further to see why it's not being defined. It looks like `context.locals.runtime.ctx` is null...
@andreiborza Fixing `wrapRequestHandler` when executed as part of `astro build` could be as simple as this: ```diff diff --git packages/cloudflare/src/request.ts packages/cloudflare/src/request.ts index 560c17afb..e42e92ad1 100644 --- packages/cloudflare/src/request.ts +++ packages/cloudflare/src/request.ts @@ -89,7...
> We'll take a look at this next week as some of us are currently out of the office. No pressure, btw. Just sharing my findings. :)
> Thanks, I think from our POV it's also important that we do have some kind of flushing ability otherwise the function could be turned off before everything is flushed...
@Lms24 Speaking of `waitUntil`, I noticed that `Sentry.captureException` won't work inside of it because the Sentry client injected via middleware might not be available in that scope. This happens, for...
> Hmm @AbhiPrasad any ideas? I'm not familiar enough with waitUntil unfortunately I would still appreciate any help here. @AbhiPrasad 🙏 Circling back to the original issue, I found out...
Last but not least, you can also combine these two options: - Use `Sentry.wrapRequestHandler` from `@sentry/cloudflare` in middleware.ts - Set up the Sentry Vite plugin for source map uploads (simply...
@rodilo Your middleware looks fine to me. I'd double-check the setup locally using `wrangler pages dev` - see https://docs.astro.build/en/guides/deploy/cloudflare/#enabling-preview-locally-with-wrangler (that whole guide is worth a read). I can't tell where...