Skip to content

Updated react example template - #627

Merged
FinnRG merged 13 commits into
oven-sh:mainfrom
rubinj30:main
Jul 15, 2022
Merged

FinnRG merged 13 commits into
oven-sh:mainfrom
rubinj30:main

Conversation

@rubinj30

Copy link
Copy Markdown
Contributor

I updated the React template to be more inline with the most recent version of create-react-app's default template, including:

  • upgraded to most recent version of react and react-dom, and made necessary usage updates
  • removed reference to jest in eslintConfig, since jest is no longer in the template
  • added reportWebVitals to be more inline with most recent version of create-react-app

Comment thread examples/react/public/index.html Outdated
Comment thread examples/react/package.json Outdated
@pnodet

pnodet commented Jul 13, 2022

Copy link
Copy Markdown
Contributor

@rubinj30 Looks like you may have commit changes to packages/bun-landing. I don't think this is necessary.

@FinnRG FinnRG left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Please undo your changes to packages/bun-landing/bun.lockb and packages/bun-landing/public/index.html

@rubinj30

Copy link
Copy Markdown
Contributor Author

Please undo your changes to packages/bun-landing/bun.lockb and packages/bun-landing/public/index.html

Done. Sorry about the delay on that.

@FinnRG

FinnRG commented Jul 15, 2022

Copy link
Copy Markdown
Contributor

LGTM, thank you for your work.

@FinnRG
FinnRG merged commit b901f55 into oven-sh:main Jul 15, 2022
dylan-conway added a commit that referenced this pull request Sep 15, 2026
Brings in, from oven-sh/WebKit main:
- #657: a suspended generator or async function keeps its scopes' SymbolTables when its
  code is generated again
- #658: MicrotaskCallCache builds its entries over zeroed storage
- #583: RunLoopBun has no weak fallback definition of Bun__thisThreadHasVM (Bun defines it)
- #627: JSModuleLoader::clearAll() pins prelinked edges in one pass, which is what
  graph.dispose() calls; it was quadratic in the size of a prelinked graph
dylan-conway added a commit that referenced this pull request Sep 15, 2026
…e try range runs into the next (oven-sh/WebKit#629) (#42787)

### What this fixes

In DFG-compiled code, a local that is live only at the head of a `catch`
handler came back as `undefined` after an exception whenever that
handler's try range was followed *directly* by another one. Two ways to
get that bytecode layout:

**`bun build --bytecode` (regression from #42002).** The bytecode
optimizer deletes the `jmp` that closes a try body once an empty `catch
{}` has been threaded to the loop header, so the catch's range falls
through into the next one. This then breaks after tier-up:

```js
function f(kind) {
  for (let name of ["a", "b"]) {
    try {
      return JSON.parse(kind === "k" && name === "b" ? "1" : "{bad"), true;
    } catch {}
  }
  return false;
}
// TypeError: undefined is not a function (near '...name of ["a", "b"]...')
```

It is not specific to for-of or to `JSON.parse`: a `while (true)` inside
`try … finally`, or a labelled `break` into code that starts with a
`try`, loses whatever only the loop uses, and when that is a number
nothing throws — a loop-only `doubled` silently became `NaN`. Building
with `--no-optimize-bytecode` / `optimize: { bytecode: false }` avoided
it.

**`using` (not a regression, all bytecode).** The dispose call's
synthesized catch range ends right at the call, inside the enclosing
handler's range. A dispose method that threw after the body also threw
reported its own `Error` instead of a `SuppressedError` carrying both,
once the function was optimized.

### Cause and fix (oven-sh/WebKit#629)

`DFG::LiveCatchVariablePreservationPhase` flushes, when the covering
exception handler changes, every local live at the catch head of the
handler being left. The lookup of the *new* handler overwrote that live
set before the flush ran, so a direct A → B transition flushed B's set
for A. Locals live only at A's catch were then dead in the block, and
the exception OSR exit to A's `op_catch` recovered them as `undefined`.
Stock `try`/`catch` always ends a range with an explicit `jmp`, so only
the two layouts above reach it.

The phase now looks the handler up, flushes with the old set, and only
then computes the new one, keyed on (handler, inline call frame) so
recursive inlining keeps following the frame. The fixing line is the
reordering in `handleBlockForTryCatch`; everything else in that diff is
the lookup returning the pair.

### Also in this WebKit range

`9b02218df662..65513e295c73`: oven-sh/WebKit#657 (suspended generators
keep their scopes' SymbolTables), #658 (MicrotaskCallCache over zeroed
storage), #583 (no weak `Bun__thisThreadHasVM` fallback — bun defines it
in `VirtualMachine.rs`), #627 (`JSModuleLoader::clearAll()` in one
pass), #624 (DFG constant-folding a module variable across an import
cycle).

### Tests

- `test/bundler/bun-build-compile.test.ts` → `locals live only at a
catch inside a loop`: builds a fixture with `bun build --bytecode` and
runs it; covers for-of (result discarded and used), `while` inside a
user `finally`, labelled `break` into a `try`, the loop-only number that
turns into `NaN`, the for-of inlined into a caller, and a recursively
inlined try/catch on source (that last one is a no-regression check for
the inline-frame keying, it passes before too). JIT thresholds are
lowered in the child's environment so DFG is reached after ~100 calls;
every case goes wrong within 70 iterations on the unfixed engine and the
test runs 300.
- `test/js/web/explicit-resource-management.test.ts` → `a dispose that
throws after the body threw reports a SuppressedError from optimized
code`.

On `1.4.3-canary.1+7e56b402b` (unfixed): the two `--bytecode` cases fail
(`loopOnlyNumber: got false:4:NaN`, `TypeError: undefined is not a
function`) and the `using` test prints `Error | undefined | undefined`.
With this PR (`bun bd test`, debug build on the published prebuilt) all
of them pass. They pass on 1.4.2 as well for the `--bytecode` part,
since that predates the optimizer.

Supersedes #37941, which pinned a preview build of an earlier, now
closed, version of the same engine fix (oven-sh/WebKit#417).
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.

4 participants