Skip to content

feat(meta): Unify detection of serverless environments and add Cloud Run #17168

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

Merged
merged 1 commit into from
Jul 25, 2025

Conversation

s1gr1d
Copy link
Member

@s1gr1d s1gr1d commented Jul 25, 2025

Adds Google Cloud Run environment variable to serverless detection to wait until flushing.

Documented here: https://cloud.google.com/run/docs/configuring/services/environment-variables#reserved

related to this: #17165

@s1gr1d s1gr1d requested review from andreiborza, Copilot and Lms24 July 25, 2025 08:15
Copilot

This comment was marked as outdated.

Copy link
Member

@Lms24 Lms24 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this is technically correct, and aligning here is fine. On that note, wdyt about maintaining this list in core instead?

However, I'm pretty sure that it's not enough for cloudflare for example, where we need Cloudflare's waitUntil helper to call

waitUntil(flush(2000))

The good news is that we get this by using the Cloudflare SDK request handler in SDKs where we support a framework on CF (like Nuxt and Sveltekit).

@@ -5,7 +5,13 @@ import { DEBUG_BUILD } from '../common/debug-build';

/** Flush the event queue to ensure that events get sent to Sentry before the response is finished and the lambda ends */
export async function flushIfServerless(): Promise<void> {
const isServerless = !!process.env.LAMBDA_TASK_ROOT || !!process.env.VERCEL;
const isServerless =
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

l: for a follow up, can we upstream this into core possibly, and re-use this in meta SDKs?

@s1gr1d
Copy link
Member Author

s1gr1d commented Jul 25, 2025

I'll create a utility for this in the core package in another PR :)

However, it's not possible to include Cloudflare's waitUntil into this function, as it exists on the ctx. So this has to be done by the Cloudflare SDK (where there is access to ctx (Cloudlfare docs).

@s1gr1d s1gr1d merged commit f0147dc into develop Jul 25, 2025
49 checks passed
@s1gr1d s1gr1d deleted the sig/add-google-cloud-run branch July 25, 2025 11:31
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants