Skip to content

ci: prepare daily upstream sync PRs - #5

Merged
vincentkoc merged 1 commit into
mainfrom
claude/add-upstream-sync
Sep 25, 2026
Merged

vincentkoc merged 1 commit into
mainfrom
claude/add-upstream-sync

Conversation

@vincentkoc

Copy link
Copy Markdown
Member

New upstream commits currently need a manually assembled fork sync. This adds a daily (06:17 UTC) and manual workflow that freezes fork/upstream SHAs, merges them into automation/sync-upstream through GitHub's API, and opens a draft PR while retaining both histories.

An open sync PR stays frozen, including after retargeting or being marked ready. Later runs reuse a branch only when its exact head matches the last merged sync PR and is already incorporated in fork main. Unknown branches, closed-unmerged reviews, conflicts, permission errors and changed PR identities stop visibly. The workflow never force-updates refs or merges a PR.

The implementation uses the repository's pinned actions/github-script and executes no imported source. .github/UPSTREAM_SYNC.md documents activation, review/native qualification, credential permissions, concurrency limits and recovery from a partially completed run. Scope: 112 workflow lines; 232 focused test lines; 87 operations-note lines; one changelog entry.

Validation:

  • node --test .github/scripts/sync-upstream.test.cjs: 24 passed on Node 26.7.0. Stateful API tests cover ancestry/merge ordering, no-op and pending runs, retargeted reviews, branch ownership, merge/PR/creation failures and exact PR identity.
  • actionlint .github/workflows/sync-upstream.yml: passed with actionlint 1.7.12.
  • git diff --check: passed.
  • Independent scoped review and maintainer source review: clear.
  • Live read-only GitHub checks verified fork ancestry comparison and PR head/base response fields. The actual upstream29d...forka524 comparison returned ahead/180, behind/0, with upstream as the merge base.

Activation remains pending review and landing. Scheduled execution and mutating token permissions have not been tested live. The default GITHUB_TOKEN produces approval-required PR CI; imported workflow changes may require an explicitly authorized repository-scoped UPSTREAM_SYNC_TOKEN with Contents, Pull requests and Workflows write permissions. No credentials or settings were provisioned.

Contracts: merge API, GITHUB_TOKEN events, workflow permissions.

@vincentkoc
vincentkoc marked this pull request as ready for review September 25, 2026 08:29
@vincentkoc
vincentkoc merged commit 699ba4d into main Sep 25, 2026
6 of 7 checks passed
@vincentkoc
vincentkoc deleted the claude/add-upstream-sync branch September 25, 2026 08:34
vincentkoc added a commit that referenced this pull request Sep 25, 2026
### What does this PR do?

Preserve a `node:http` request body when its response finishes before the upload does.

Response completion previously cleared the native body callback and marked the request done. That could truncate an upload, report false EOF, or let socket/pipeline resume consume bytes before the request reader received them.

- Keep the Node request's native stream and callback alive until wire completion or cancellation.
- Drain buffered bytes only through the request owner. Socket resume now controls transport flow without consuming the body.
- Distinguish cancellation from completed input, preserve pipeline callback ownership, and keep active uploads out of idle-connection cleanup.
- Remove the superseded socket-level body-EOF and drain paths. `Bun.serve` retains its separate completion contract.

Production delta: +126/-220, net -94 lines. Tests: +556/-26. One fork changelog entry. No public API, configuration, dependency, or runtime-pin changes.

### How did you verify your code works?

The eight runtime/test files at `330ae557b52416ebe794c27d15972b3f63abeff6` are byte-identical to reviewed and tested `697026816ab70d5a14189fd43209b57b3982baa1`; only the changelog entry was added afterward. Follow-up `3c3c4c3ad07f45ec437cf5091706ef59ad3bbe6c` declares the existing required `_dumped` field in the module-local request type after CI exposed the missing declaration. It does not change runtime behavior or public types.

On Linux x64, using the maintained fork base `699ba4ddd138994fb258de53669d481cdcf1016d`, WebKit `35e8970dfd926abf6661c9d356f5d60d8f611c9b`, and verified source hashes:

- Unpatched maintained debug/ASAN baseline: 11 passed, 9 failed with the earlier 20-case fixture revision `aab7508b`, before the pipeline case was strengthened. The nine failing cases reproduce premature completion, disconnect handling, and active-upload idle closure; they are unchanged in the final fixture.
- Patched `bun bd test test/js/node/http/node-http-req-socket-pause.test.ts`: 20/20 passed, 4.99 seconds.
- Patched `bun run build:release -j8 test test/js/node/http/node-http-req-socket-pause.test.ts`: 20/20 passed, 126 milliseconds; native release build passed.
- The identical `node:test` file under Node 26.7.0: 20/20 passed.
- Raw-socket early-response probe under debug/ASAN and release: exact 2 MiB response, complete upload tail, same-connection pipelined GET, incomplete-upload disconnect, and joined cleanup passed.
- Node HTTP request-body backpressure: 5/5 passed. Pipeline callbacks, mid-upload half-close, and abort-event siblings passed.
- `Bun.serve` request-body backpressure: 6/6 passed. Body-limit and handler-triggered stop siblings: 3/3 passed.
- Node and Bun proxy compatibility controls: 7/7 each after installing the existing locked test dependencies.
- Independent P0-P2 review and `git diff --check` passed.

On the final typed candidate, `bun run build:types` and the native `tsc --noEmit` projects for `src/js`, `src`, and `src/runtime/bake` passed. Fresh debug/ASAN and release reruns passed 20/20 each (5.00 seconds and 125 milliseconds). All eight source hashes were checked before and after execution; both executable hashes remained unchanged. Independent P0-P2 review of the declaration-only follow-up also passed.

The wrapper-selected release executable was verified as `bun-profile`, SHA256 `134635e80682dd378843212b6a8a4dea22a16819dca6741e2cbe8ccf71358402`. Its full source overlay was checked before execution. This is a locally built fork candidate, not a claim that the unchanged published OpenClaw Bun pin contains the fix.

Known separate baseline failure: `CONNECT: process exits after the tunnel socket is re-emitted as a connection and the server closes` times out identically on the unpatched maintained base and this candidate. The existing upstream repair oven-sh#43557 includes idle-tunnel loop-liveness accounting in oven-sh@811f817. Follow-up: qualify that owner-level repair against the maintained fork. This PR does not weaken the assertion or timeout, and the baseline observation is not a claim of reproduction on current upstream main.

Separate automation follow-up: **Bun fork issue-finder automation ownership**. The Claude issue-matching workflow fails before analysis because its Anthropic authentication is unavailable. The identical workflow also failed on the unaffected #5 at https://github.com/openclaw/bun/actions/runs/36108378740/job/107986018509. No credentials, workflow guards, or CI requirements are changed here.

The broader OpenClaw proxy/UI/QA campaign is still running. This PR does not claim the entire Bun compatibility suite or all-platform CI is green.
steipete pushed a commit to fuller-stack-dev/bun that referenced this pull request Oct 20, 2026
…module-graph.test.ts (oven-sh#45674)

### What does this PR do?

Fixes the flaky "50 graphs alive at once, each with its own state, then
all exit and are collected" in
`test/js/bun/module-graph/module-graph.test.ts`. It failed in 2 of 31
builds of main, 125686 to 127114 (Ubuntu 25.04 x64, Windows 11 aarch64)
and passed on the retry.

The test registered one array, `graphs[25].big`, with a
`FinalizationRegistry` and failed if 100 collections did not finalize
it. It now tracks the array of every one of the 50 graphs with
`Lifetimes` from `module-graph-lifetimes.ts`, as
`module-graph-gc.test.ts` does. There, an object that is not finalized
counts as kept alive only if a root reaches it in the debugging heap
snapshot, and the failure message is the path from that root.

Two things change with the helper, and the first is what makes the runs
below pass:

1. **Where the collection runs.** The helper calls `Bun.gc(true)` from a
timer callback, main's `collected()` from the continuation of the async
test. The `runInternalMicrotask` frame that holds the stale word
(artifact 2) is not on the stack in a timer callback. In 240 of 240 runs
all 50 arrays were finalized by the first collection.
2. **What is asserted if one is left.** Not that it was finalized, but
that no root reaches it.

### Why it failed

On main one of the 50 graphs outlives the collections in almost every
run, and the test fails when that one is number 25. Whole file, CI's
environment, 840 runs:

| graphs left after the collections | 0 | 1 | 2 | 3 |
|---|---|---|---|---|
| runs | 2 | 802 | 3 | 33 |

12 of the 840 failed. In the failing runs looked at (9 heap snapshots,
12 stack dumps) nothing in the heap holds the one that is left, and one
word on the native stack points at it.

All of what follows is the Linux x64 binary that CI built for main at
7f3bc6a, with `BUN_GARBAGE_COLLECTOR_LEVEL=1
BUN_RUNTIME_TRANSPILER_CACHE_PATH=0` as in `scripts/runner.node.ts`. The
failure needs both that environment and the whole file: 0 of 240 without
the environment, 0 of 1600 with the test alone. I did not look at the
Windows failure.

<details><summary>Artifact 1: the heap snapshot</summary>

`generateHeapSnapshotForDebugging()` right after the 100 collections.
These are the array and every cell from which it can be reached:

```
snapshot: 27033 cells, 99750 edges, 586 roots; arrays named `big` still in it: 1
  cell   1532 Promise                0x34cf520fa40  incoming edges 0  in `roots` no  a root reaches it no
  cell   1555 ModuleRecord           0x34cf527e980  incoming edges 3  in `roots` no  a root reaches it no
  cell   1573 ModuleNamespaceObject  0x34cef51dd50  incoming edges 3  in `roots` no  a root reaches it no
  cell   1591 JSModuleEnvironment    0x34cf5278950  incoming edges 3  in `roots` no  a root reaches it no
  cell   1626 Array                  0x34cef3755a0  incoming edges 2  in `roots` no  a root reaches it no
  cell   1631 Function               0x34cef45a100  incoming edges 2  in `roots` no  a root reaches it no
  cell   1653 Function               0x34cef45a0e0  incoming edges 2  in `roots` no  a root reaches it no
```

The snapshots of 8 other failing runs have the same seven kinds of cell,
with the `Promise` (fulfilled with the `ModuleRecord`) as the only one
without an incoming edge.
</details>

<details><summary>Artifact 2: the stack word and the frame that owns it
(gdb, same run as artifact 1)</summary>

The test writes the snapshot and sends itself SIGUSR2, and gdb stops
there.

```
Thread 1 "bun-profile" received signal SIGUSR2, User defined signal 2.
(gdb) info registers rsp rbp
rsp            0x7fffffffa0c8
rbp            0x7fffffffa240

words in [rsp, end of stack) = [0x7fffffffa0c8, 0x7ffffffff000) that point into one of those cells: 1
  0x7fffffffa8a0 holds 0x34cf520fa40 = Promise+0; it lies in the frame with rbp 0x7fffffffa8f0, at rbp-0x50
(gdb) x/gx 0x7fffffffa8a0
0x7fffffffa8a0:	0x0000034cf520fa40
(gdb) info symbol 0x1bccee0        # where that frame's callee returns to
JSC::runInternalMicrotask(...) + 6976

rbp chain
  openclaw#3  rbp 0x7fffffffa540  Bun::Process_functionKill
  openclaw#4  rbp 0x7fffffffa550  (JIT code)
  openclaw#5  rbp 0x7fffffffa5d0  op_call_ignore_result_return_location
  openclaw#6  rbp 0x7fffffffa680  llint_call_javascript
  openclaw#7  rbp 0x7fffffffa7e0  JSC::asyncFunctionGeneratorBodyCall
  openclaw#8  rbp 0x7fffffffa8f0  JSC::runInternalMicrotask            <- owns 0x7fffffffa8a0
  openclaw#9  rbp 0x7fffffffab70  JSC::MicrotaskQueue::drainWithUseCallOnEachMicrotask
  openclaw#10 rbp 0x7fffffffac00  JSC::VM::drainMicrotasks
  openclaw#11 rbp 0x7fffffffac20  Zig::GlobalObject::drainMicrotasks
  openclaw#12 rbp 0x7fffffffac50  <bun_jsc::event_loop::EventLoop>::exit
  openclaw#13 rbp 0x7fffffffacf0  TimerObjectInternals::fire
```

12 failing runs that dumped their own stack from `/proc/self/mem` show
the same: one word, `Promise+0`, at `rbp-0x50` of
`runInternalMicrotask`. In the 5 of them where I looked for it, the
frame's callee returns to the same `0x1bccee0`, which is
`JSMicrotask.cpp:2053`.

**Who wrote it.** A hardware watchpoint on `0x7fffffffa8a0`, set at the
first line of the test, sees 10 writes. The last one is the `Promise`:
`pushq %r14` in the prologue of `JSC::ModuleGraphLoadingState::create`
(`ModuleGraphLoadingState.cpp:71`, rbp `0x7fffffffa8b0`), which saves a
register of its caller.

**Why it stays.** The 100 collections run in the continuation of an
async function, so each runs under a `runInternalMicrotask` frame at
that same address. In the disassembly the function has 9 stores to
`-0x50(%rbp)`. Following the jump table and every branch, only case 14
of the switch (resume an async function) reaches the call at
`JSMicrotask.cpp:2053`, and none of the 9 stores is on a way to it. The
slot is inside a live frame, so stack sanitizing does not cover it.

So the graph that is left is the one whose load called `create` last at
that depth.
</details>

### How did you verify your code works?

**Failure rate.** Whole file, 12 copies side by side, main and this PR
in alternating rounds:

| | main | this PR |
|---|---|---|
| runs that failed | 12 of 1200 (all this test) | 0 of 1200 |

**What the snapshot says about a survivor.** With this PR there was none
to ask about: in those 240 runs, with a logging copy of the helper, the
snapshot was never taken. So this is main's test as it is, followed by
the helper's `Heap` asked about the 50 addresses, 1080 runs. The old
assertion failed in 12 of them. In 11 the array was in the snapshot with
no root reaching it, in 1 it was gone by then, in 0 a root reached it.

In 7 of the 1080 runs a root did reach two other arrays. In the one run
whose paths were printed, both start at `root(JITWorkList)`, a
compilation that is still running. `stillAlive` goes on collecting while
a root reaches something.

**Real references must fail.** One line added before `graphs.length =
0`. All 9 fail, with these messages:

| graph 25 is held by | message |
|---|---|
| a global, the namespace | `root(ProtectedValues) GlobalObject
-Property:held-> ModuleNamespaceObject -> ModuleRecord ->
JSModuleEnvironment -> Array` |
| a global closure over `inc` | `root(ProtectedValues) GlobalObject
-Property:held-> Function -> JSLexicalEnvironment -Variable:inc->
Function(inc) -> JSModuleEnvironment -> Array` |
| a local of the suspended test | `root(Output) FunctionCodeBlock -> ...
-Variable:pendingHeap-> Promise -> AsyncFunctionGenerator -> ...` |
| `setInterval(inc)` | `root(StrongHandles) StrongRootBlock -> Timeout
-Property:callback-> Function(inc) -> JSModuleEnvironment
-Variable:big-> Array` |
| `process.on(..., inc)` | `root(ProtectedValues) GlobalObject ->
Process -> Function(inc) -> JSModuleEnvironment -Variable:big-> Array` |
| a reaction of a pending promise | `root(ProtectedValues) GlobalObject
-Property:held-> Promise -> Function(inc) -> JSModuleEnvironment
-Variable:big-> Array` |
| a `FinalizationRegistry` held value | `root(ProtectedValues)
GlobalObject -Property:held-> FinalizationRegistry -> Array` |
| a `WeakMap` value of a live key | `root(Output) Array` |
| an `AbortSignal` listener | `root(WeakSets) AbortSignal ->
Function(inc) -> JSModuleEnvironment -Variable:big-> Array` |

With `globalThis.held = graphs[7]` instead, main's test passes 5 of 5
and this PR's fails 5 of 5.

**Debug build**, default timeout: the test passes 6 of 6 alone and in 6
of 6 runs of the whole file.
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