Skip to content

Conversation

vercel-ai-sdk[bot]
Copy link
Contributor

@vercel-ai-sdk vercel-ai-sdk bot commented Oct 11, 2025

This is an automated backport of #9411 to the release-v5.0 branch.

@gr2m gr2m marked this pull request as ready for review October 11, 2025 18:46
console.log('\nTo fix this, either:');
console.log('1. Reduce the bundle size by optimizing code');
console.log(
'2. Update the limit at https://github.com/vercel/ai/settings/variables/actions/BUNDLE_SIZE_LIMIT_KB',
Copy link
Contributor

Choose a reason for hiding this comment

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

The error message suggests updating a GitHub Actions variable BUNDLE_SIZE_LIMIT_KB, but the script uses a hardcoded limit and doesn't read from any environment variable, making this guidance ineffective and misleading.

View Details
📝 Patch Details
diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml
index 1b3e5e73c..8b415be31 100644
--- a/.github/workflows/ci.yml
+++ b/.github/workflows/ci.yml
@@ -132,6 +132,8 @@ jobs:
         run: pnpm run build:packages
 
       - name: Check bundle size
+        env:
+          BUNDLE_SIZE_LIMIT_KB: ${{ vars.BUNDLE_SIZE_LIMIT_KB }}
         run: cd packages/ai && pnpm run check-bundle-size
 
       - name: Upload bundle size metafiles
diff --git a/packages/ai/scripts/check-bundle-size.ts b/packages/ai/scripts/check-bundle-size.ts
index ff8cf4ad0..610c3713e 100644
--- a/packages/ai/scripts/check-bundle-size.ts
+++ b/packages/ai/scripts/check-bundle-size.ts
@@ -3,7 +3,9 @@ import { writeFileSync, statSync } from 'fs';
 import { join } from 'path';
 
 // Bundle size limits in bytes
-const LIMIT = 510 * 1024;
+const LIMIT = process.env.BUNDLE_SIZE_LIMIT_KB
+  ? parseInt(process.env.BUNDLE_SIZE_LIMIT_KB, 10) * 1024
+  : 510 * 1024;
 
 interface BundleResult {
   size: number;

Analysis

Bundle size check error message references non-functional GitHub Actions variable

What fails: The check-bundle-size.ts script error message at line 109 instructs users to update BUNDLE_SIZE_LIMIT_KB at https://github.com/vercel/ai/settings/variables/actions/BUNDLE_SIZE_LIMIT_KB, but the script hardcodes the limit at line 6 (const LIMIT = 510 * 1024;) and never reads from environment variables.

How to reproduce:

# The script uses hardcoded value:
cd packages/ai
grep "const LIMIT" scripts/check-bundle-size.ts
# Output: const LIMIT = 510 * 1024;

# The script doesn't use process.env:
grep "process.env" scripts/check-bundle-size.ts
# Output: (none)

# CI workflow doesn't pass the variable:
grep -A5 "Check bundle size" .github/workflows/ci.yml
# Shows no env vars passed to the script

Result: When a bundle size check fails, users follow the error message guidance to update the GitHub Actions variable, but the script continues failing because it never reads that variable. This wastes developer time troubleshooting why their configuration change has no effect.

Expected: The script should read from process.env.BUNDLE_SIZE_LIMIT_KB and the CI workflow should pass to the script, making the error message's guidance functional.

Fix: Modified the script to read from environment variable with fallback to hardcoded default, and updated the CI workflow to pass the GitHub Actions variable per GitHub Actions variables documentation.

@gr2m gr2m enabled auto-merge (squash) October 13, 2025 18:17
@gr2m gr2m merged commit b75f401 into release-v5.0 Oct 13, 2025
11 checks passed
@gr2m gr2m deleted the backport-pr-9411-to-release-v5.0 branch October 13, 2025 18:18
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.

1 participant