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
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions packages/nuxt/src/runtime/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,7 @@ export async function flushIfServerless(): Promise<void> {
const isServerless =
!!process.env.FUNCTIONS_WORKER_RUNTIME || // Azure Functions
!!process.env.LAMBDA_TASK_ROOT || // AWS Lambda
!!process.env.K_SERVICE || // Google Cloud Run
!!process.env.CF_PAGES || // Cloudflare
!!process.env.VERCEL ||
!!process.env.NETLIFY;
Expand Down
8 changes: 7 additions & 1 deletion packages/solidstart/src/server/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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?

!!process.env.FUNCTIONS_WORKER_RUNTIME || // Azure Functions
!!process.env.LAMBDA_TASK_ROOT || // AWS Lambda
!!process.env.K_SERVICE || // Google Cloud Run
!!process.env.CF_PAGES || // Cloudflare
!!process.env.VERCEL ||
!!process.env.NETLIFY;

if (isServerless) {
try {
Expand Down
10 changes: 8 additions & 2 deletions packages/sveltekit/src/server-common/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,15 @@ export async function flushIfServerless(): Promise<void> {
return;
}

const platformSupportsStreaming = !process.env.LAMBDA_TASK_ROOT && !process.env.VERCEL;
const isServerless =
!!process.env.FUNCTIONS_WORKER_RUNTIME || // Azure Functions
!!process.env.LAMBDA_TASK_ROOT || // AWS Lambda
!!process.env.K_SERVICE || // Google Cloud Run
!!process.env.CF_PAGES || // Cloudflare
!!process.env.VERCEL ||
!!process.env.NETLIFY;

if (!platformSupportsStreaming) {
if (isServerless) {
Copy link
Preview

Copilot AI Jul 25, 2025

Choose a reason for hiding this comment

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

[nitpick] The logic inversion from checking !platformSupportsStreaming to isServerless changes the semantic meaning. Consider renaming the variable to platformRequiresFlushing or shouldFlushForPlatform to better reflect that this determines when flushing is needed, not just whether the platform is serverless.

Suggested change
if (isServerless) {
if (platformRequiresFlushing) {

Copilot uses AI. Check for mistakes.

try {
DEBUG_BUILD && debug.log('Flushing events...');
await flush(2000);
Expand Down
Loading