-
Notifications
You must be signed in to change notification settings - Fork 5k
Extend ForeignRef<T> to the rest of the owned C/C++ FFI handles #33887
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
Jarred-Sumner
merged 3 commits into
claude/foreign-owned-fetch-headers
from
claude/foreign-owned-batch
Jul 10, 2026
Merged
Changes from all commits
Commits
Show all changes
3 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,59 @@ | ||
| --- | ||
| name: verify | ||
| description: Build Bun and drive the changed code at its real surface (CLI, socket, FFI) to observe it running. | ||
| --- | ||
|
|
||
| # Verifying a change to Bun | ||
|
|
||
| **Build:** `bun bd` (no timeout — it can take many minutes). Exit 0 is setup, not evidence. | ||
|
|
||
| **Drive:** `bun bd run <script.js>` builds *and* runs, forwarding args to the debug binary. | ||
| Put driver scripts under `~/code/tmp/**` — Santa blocks unsigned executables elsewhere. | ||
|
|
||
| ## Two ways to invoke the debug build | ||
|
|
||
| | Need | Use | | ||
| |---|---| | ||
| | run a script, stay in the repo | `bun bd run /path/to/drive.js` | | ||
| | any command, from another cwd | `/Users/jarred/code/bun/build/debug/bun-debug <cmd>` | | ||
|
|
||
| `bun bd` is a **package.json script** — it only resolves with the repo root as cwd. | ||
| A probe that `cd`s into a temp dir must call the binary by absolute path. | ||
| The binary refuses `bun-debug test <file>` on purpose ("use `bun bd test`"); every other | ||
| subcommand (`pm pack`, `install`, `build`, `run`) works directly. Directory args to | ||
| `bun-debug test` also trip a filter guard — pass explicit file paths. | ||
|
|
||
| ## Surfaces, by what you touched | ||
|
|
||
| | Changed | Drive it with | | ||
| |---|---| | ||
| | `src/uws_sys/**`, `src/runtime/server/**` | `Bun.serve({port:0})` + real `fetch()`; `routes:` for static routes | | ||
| | WebSocket / `Response::upgrade` | `Bun.serve` + `new WebSocket(...)`, echo a `Uint8Array` | | ||
| | TLS / `SSL_CTX` | `Bun.serve({tls:{cert,key}})` + `fetch(https, {tls:{rejectUnauthorized:false}})`. Make a cert with `openssl req -x509 -newkey rsa:2048 -nodes -subj /CN=localhost -addext subjectAltName=DNS:localhost` | | ||
| | `ConnectingSocket` (connect-failure path) | `Bun.connect()` to a port you opened then closed → `connectError` fires | | ||
| | `src/runtime/bake/**` (dev server) | run `bun-debug index.html --port 0`, read the URL off stdout, then open `ws://host:port/_bun/hmr` | | ||
| | `libdeflate`, `zstd`, `node:zlib` | `Bun.gzipSync`/`gunzipSync`, `Bun.zstdCompressSync`, `zlib.brotliCompress`. Feed garbage in too — it must throw, not crash | | ||
| | `libarchive` | write side = `bun-debug pm pack`; read side = `bun-debug install ./x.tgz --no-save`, then check the extracted file exists | | ||
| | `src/jsc/CachedBytecode.rs` | `bun-debug build x.js --bytecode --target=bun --outdir=out` then run `out/x.js` | | ||
| | `src/tcc_sys/**` | `import { cc } from "bun:ffi"` and call a compiled C symbol | | ||
| | Yarr `RegularExpression` | `.npmrc` with `public-hoist-pattern[]=*x*`, then `bun-debug install --dry-run` | | ||
| | `TextCodec` | `TextDecoder`, including `{stream:true}` across a split multi-byte codepoint | | ||
| | `JSUint8Array` | `crypto.getRandomValues(new Uint8Array(n))` (DOMJIT fast path); `ws.send(bytes)` | | ||
| | `SourceProvider` | `new Error().stack` must contain `file:line` | | ||
| | `Strong` / `Weak` | `WeakRef` + `Bun.gc(true)`; churn thousands of promises | | ||
|
|
||
| ## Gotchas that cost real time | ||
|
|
||
| - **A debug assert you add is only real if it's in the binary**: `strings build/debug/bun-debug | rg '<your panic message>'`. | ||
| - **`cargo check` is not an oracle.** It never monomorphizes, so it never evaluates | ||
| `const { assert!(...) }` inside a generic fn (`bun_opaque::opaque_deref*`). Finish with | ||
| `cargo build -p bun_bin` or `bun bd`. | ||
| - **Generated code is built by ninja, not cargo.** `build/debug/codegen/*.rs` goes stale under | ||
| a bare `cargo check`. Regenerate a single file with e.g. | ||
| `bun src/codegen/generate-host-exports.ts build/debug/codegen`, or just run `bun bd`. | ||
| - **Multi-file test runs share one process.** RSS/GC assertions (`gcUntilCountAtMost`, | ||
| "does not leak memory") and tests that mutate process globals (`buffer.kMaxLength`) fail | ||
| when run alongside other files even with `--isolate`. Re-run the file alone before believing it. | ||
| - **Compare against a baseline binary, not intuition.** `~/code/bun-3` tracks `main` and usually | ||
| has a built `build/debug/bun-debug`. Run the same file with it to tell a regression from a | ||
| pre-existing flake. | ||
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🟡 This skill file hardcodes contributor-specific absolute paths (
/Users/jarred/code/bun/build/debug/bun-debugon line 18,~/code/bun-3on line 58) and a macOS-only Santa MDM constraint (line 11). Since.claude/skills/is checked in and loaded by every contributor's Claude Code session, agents on other machines will follow these instructions verbatim and hit ENOENT — consider using repo-relative./build/debug/bun-debugor marking these as environment-specific placeholders.Extended reasoning...
What the issue is
The new
.claude/skills/verify/SKILL.mdcontains three environment-specific references:Put driver scripts under ~/code/tmp/** — Santa blocks unsigned executables elsewhere.— Santa is a macOS-only binary-authorization MDM tool. Contributors on Linux (or macOS without corporate MDM) have no such restriction, and~/code/tmp/may not exist.| any command, from another cwd | /Users/jarred/code/bun/build/debug/bun-debug <cmd> |— an absolute path rooted at one specific contributor's home directory.~/code/bun-3 tracks main and usually has a built build/debug/bun-debug— references a second personal checkout that won't exist on other machines.Why it matters here
Unlike a personal note or a scratch script,
.claude/skills/verify/SKILL.mdis checked into the repository. Per Claude Code's skill mechanism, every contributor's agent will load this file and follow its instructions verbatim when asked to verify a change. The PR description explicitly says "Also adds averifyskill capturing the build-and-drive recipe", so the intent is for this to be shared tooling.Concrete failure
A contributor on Linux with the repo cloned at
/home/alice/buninvokes theverifyskill. The agent, following line 18's instruction for "any command, from another cwd", runs:This fails with
No such file or directory. Similarly, an agent trying to "compare against a baseline binary" per line 58 willcd ~/code/bun-3and fail. The Santa reference on line 11 will lead a Linux agent to needlessly restrict where it writes driver scripts.Why nothing prevents it
There is no indirection or placeholder marker — the paths are presented as literal instructions in a table and prose. The skill's own header says "Build Bun and drive the changed code", positioning it as general-purpose. Nothing in the file signals "adjust these paths for your machine."
Suggested fix
Replace the absolute path with the repo-relative form the rest of the repo already uses (CLAUDE.md documents
./build/debug/bun-debug), and either drop the Santa/~/code/bun-3references or annotate them as environment-specific. For line 18 specifically, something like$PWD/build/debug/bun-debug(run from the repo root) or<repo>/build/debug/bun-debugwould be portable.This is documentation rather than runtime code — nothing crashes at build or test time — so it's a nit, but checked-in agent instructions should work for everyone who clones the repo.