Skip to content

fix(cmake): use GITHUB_TOKEN for dependency downloads to avoid rate limits#27334

Open
dylan-conway wants to merge 3 commits intomainfrom
claude/github-token-downloads
Open

fix(cmake): use GITHUB_TOKEN for dependency downloads to avoid rate limits#27334
dylan-conway wants to merge 3 commits intomainfrom
claude/github-token-downloads

Conversation

@dylan-conway
Copy link
Member

When GITHUB_TOKEN is set in the environment, pass an Authorization: Bearer header on downloads from github.com. This raises the API rate limit from 60 to 5,000 requests/hour, which prevents the frequent download failures seen in CI when many dependencies are fetched in parallel.

  • Only applies to github.com URLs — non-GitHub downloads are unaffected
  • No-op when GITHUB_TOKEN is not set — fully backwards compatible
  • GitHub Actions automatically provides GITHUB_TOKEN to workflows

…imits

Pass Authorization header for GitHub URLs when GITHUB_TOKEN is set.
Raises the rate limit from 60 to 5000 requests/hour, preventing
download failures when many dependencies are fetched in parallel.

Only applies to github.com URLs. No-op when GITHUB_TOKEN is unset.
@robobun
Copy link
Collaborator

robobun commented Feb 21, 2026

Updated 5:24 PM PT - Feb 21st, 2026

@dylan-conway, your commit b3b80ec has 7 failures in Build #37892 (All Failures):


🧪   To try this PR locally:

bunx bun-pr 27334

That installs a local version of the PR into your bun-27334 executable, so you can run:

bun-27334 --bun

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Feb 21, 2026

No actionable comments were generated in the recent review. 🎉


Walkthrough

Adds Authorization header support for GitHub token in download calls; replaces a single WebKit download with a three-attempt retry loop, cleans up cache and existing WEBKIT_PATH after extraction, and performs an OS-specific post-download adjustment on macOS.

Changes

Cohort / File(s) Summary
Download helper
cmake/scripts/DownloadUrl.cmake
When DOWNLOAD_URL targets github.com and GITHUB_TOKEN is present, set DOWNLOAD_AUTH_HEADER to Authorization: Bearer $ENV{GITHUB_TOKEN} and pass it as an HTTPHEADER to file(DOWNLOAD) (+7/-1).
WebKit setup
cmake/tools/SetupWebKit.cmake
Replace single download with up to three attempts: on failure log warning, remove cached file, wait 5s, retry; fatal error if all fail. After extraction, remove archive, remove existing WEBKIT_PATH, move extracted bun-webkit from cache to WEBKIT_PATH; on Apple remove WEBKIT_INCLUDE_PATH/unicode (+15/-7).
Test script
scripts/verify-baseline.ts
Add Windows-specific skip list for JIT-stress Wasm/JS fixtures: create skipFixtures set and skip tail-call-should-consume-stack-in-bbq.js on Windows; filter excludes files in the set (+6/-1).
🚥 Pre-merge checks | ✅ 2
✅ Passed checks (2 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly describes the main change: using GITHUB_TOKEN for dependency downloads to avoid rate limits, which aligns with the primary objective of the PR.
Description check ✅ Passed The description addresses both required template sections: explains what the PR does (adds Authorization header support) and provides verification context (GitHub Actions integration and backwards compatibility).

✏️ Tip: You can configure your own custom pre-merge checks in the settings.


Comment @coderabbitai help to get the list of available commands and usage tips.

@claude
Copy link
Contributor

claude bot commented Feb 21, 2026

Newest first

b3b80 — Looks good!

Reviewed 3 files across cmake/scripts/, cmake/tools/, and scripts/: Adds GitHub token-based authorization to CMake dependency downloads to avoid API rate limits, adds retry logic with 5-second delays for WebKit downloads, and skips a slow WASM tail-call test fixture on Windows.

Previous reviews

98064 — Looks good!

Reviewed 2 files across cmake/scripts/ and cmake/tools/: Adds GitHub token authentication to CMake dependency downloads and retry logic for WebKit downloads to improve CI reliability.

Previous reviews

e6237 — Looks good!

Reviewed 1 file in cmake/scripts/: Adds GitHub token authentication support to the CMake dependency download script, passing an Authorization: Bearer header for github.com URLs to raise the API rate limit from 60 to 5,000 requests/hour during CI builds.

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 1

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (1)
cmake/tools/SetupWebKit.cmake (1)

265-267: 🧹 Nitpick | 🔵 Trivial

Consider adding a comment explaining why unicode directory is removed on Apple.

This Apple-specific cleanup isn't immediately obvious. A brief comment explaining the rationale (e.g., "Use system ICU headers instead of bundled ones") would improve maintainability.

📝 Suggested documentation improvement
 if(APPLE)
+  # Use system ICU unicode headers instead of bundled ones on macOS
   file(REMOVE_RECURSE ${WEBKIT_INCLUDE_PATH}/unicode)
 endif()
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@cmake/tools/SetupWebKit.cmake` around lines 265 - 267, Add a brief
explanatory comment above the APPLE conditional that removes the unicode
directory to state why we remove it on macOS (e.g., "On Apple platforms use
system ICU / system Unicode headers instead of the bundled WebKit unicode/
headers to avoid conflicts"), so place the comment immediately before the
if(APPLE) ... file(REMOVE_RECURSE ${WEBKIT_INCLUDE_PATH}/unicode) endif() block
to clarify the rationale for future maintainers.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In `@cmake/tools/SetupWebKit.cmake`:
- Around line 244-258: The WebKit download loop uses CMake's file(DOWNLOAD)
without Authorization, so change it to call the existing DownloadUrl.cmake
helper (as DownloadZig.cmake does) via execute_process and pass
DOWNLOAD_URL=${WEBKIT_DOWNLOAD_URL} and
DOWNLOAD_PATH=${CACHE_PATH}/${WEBKIT_FILENAME}, or alternatively add an
HTTPHEADER using the GITHUB_TOKEN check to the file(DOWNLOAD) invocation; prefer
the DownloadUrl.cmake approach because it supplies the Authorization header,
longer retry logic and extraction, and replace the manual retry loop around
WEBKIT_DOWNLOAD_ATTEMPT with the helper invocation (retain the variables
WEBKIT_DOWNLOAD_URL, CACHE_PATH, WEBKIT_FILENAME for parameter names).

---

Outside diff comments:
In `@cmake/tools/SetupWebKit.cmake`:
- Around line 265-267: Add a brief explanatory comment above the APPLE
conditional that removes the unicode directory to state why we remove it on
macOS (e.g., "On Apple platforms use system ICU / system Unicode headers instead
of the bundled WebKit unicode/ headers to avoid conflicts"), so place the
comment immediately before the if(APPLE) ... file(REMOVE_RECURSE
${WEBKIT_INCLUDE_PATH}/unicode) endif() block to clarify the rationale for
future maintainers.

Comment on lines +244 to +258
foreach(WEBKIT_DOWNLOAD_ATTEMPT RANGE 1 3)
file(
DOWNLOAD ${WEBKIT_DOWNLOAD_URL} ${CACHE_PATH}/${WEBKIT_FILENAME} SHOW_PROGRESS
STATUS WEBKIT_DOWNLOAD_STATUS
)
if("${WEBKIT_DOWNLOAD_STATUS}" MATCHES "^0;")
break()
endif()
message(WARNING "WebKit download attempt ${WEBKIT_DOWNLOAD_ATTEMPT} failed: ${WEBKIT_DOWNLOAD_STATUS}")
file(REMOVE ${CACHE_PATH}/${WEBKIT_FILENAME})
if(WEBKIT_DOWNLOAD_ATTEMPT EQUAL 3)
message(FATAL_ERROR "Failed to download WebKit after 3 attempts: ${WEBKIT_DOWNLOAD_STATUS}")
endif()
execute_process(COMMAND ${CMAKE_COMMAND} -E sleep 5)
endforeach()
Copy link
Contributor

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🟠 Major

🧩 Analysis chain

🏁 Script executed:

#!/bin/bash
# Search for DownloadUrl.cmake to verify its existence
echo "=== Searching for DownloadUrl.cmake ==="
fd -t f "DownloadUrl.cmake"

echo -e "\n=== CMake files in cmake/scripts directory ==="
find cmake/scripts -type f -name "*.cmake" 2>/dev/null | sort

echo -e "\n=== All cmake files that reference DOWNLOAD or DownloadUrl ==="
rg "DOWNLOAD|DownloadUrl" --type cmake -l

echo -e "\n=== Check cmake/tools/SetupWebKit.cmake for context ==="
fd -t f "SetupWebKit.cmake" --exec wc -l {} \;

Repository: oven-sh/bun

Length of output: 678


🏁 Script executed:

#!/bin/bash
echo "=== Content of DownloadUrl.cmake ==="
cat -n cmake/scripts/DownloadUrl.cmake

echo -e "\n=== Content of DownloadZig.cmake (similar use case) ==="
cat -n cmake/scripts/DownloadZig.cmake

echo -e "\n=== SetupWebKit.cmake full content ==="
cat -n cmake/tools/SetupWebKit.cmake

Repository: oven-sh/bun

Length of output: 18634


WebKit download doesn't use GITHUB_TOKEN authentication, unlike similar downloads in the codebase.

The PR objective is to add Authorization: Bearer $GITHUB_TOKEN headers for downloads from github.com to increase the rate limit. However, this file uses the native CMake file(DOWNLOAD) command without any authorization headers, while WebKit is downloaded from https://github.com/oven-sh/WebKit/releases/download/...

The DownloadUrl.cmake module already provides this functionality and is successfully used by DownloadZig.cmake for a similar Zig release download from github.com. The recommended approach is to use the same pattern:

  1. Call DownloadUrl.cmake via execute_process (as DownloadZig.cmake does) with DOWNLOAD_URL and DOWNLOAD_PATH parameters, or
  2. Add the HTTPHEADER with GITHUB_TOKEN check directly to the file(DOWNLOAD) command.

Using DownloadUrl.cmake is preferable because it also provides automatic retry logic (10 retries vs. the current 3) and handles archive extraction.

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@cmake/tools/SetupWebKit.cmake` around lines 244 - 258, The WebKit download
loop uses CMake's file(DOWNLOAD) without Authorization, so change it to call the
existing DownloadUrl.cmake helper (as DownloadZig.cmake does) via
execute_process and pass DOWNLOAD_URL=${WEBKIT_DOWNLOAD_URL} and
DOWNLOAD_PATH=${CACHE_PATH}/${WEBKIT_FILENAME}, or alternatively add an
HTTPHEADER using the GITHUB_TOKEN check to the file(DOWNLOAD) invocation; prefer
the DownloadUrl.cmake approach because it supplies the Authorization header,
longer retry logic and extraction, and replace the manual retry loop around
WEBKIT_DOWNLOAD_ATTEMPT with the helper invocation (retain the variables
WEBKIT_DOWNLOAD_URL, CACHE_PATH, WEBKIT_FILENAME for parameter names).

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.

2 participants