Skip to content
Permalink

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also or learn more about diff comparisons.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also . Learn more about diff comparisons here.
base repository: facebook/react
Failed to load repositories. Confirm that selected base ref is valid, then try again.
Loading
base: 2d16326d
Choose a base ref
...
head repository: facebook/react
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: 459fd418
Choose a head ref
  • 15 commits
  • 66 files changed
  • 5 contributors

Commits on Sep 30, 2024

  1. [compiler][test fixtures] Fork more fixtures for hir-rewrite

    Followup from #30894 , not sure how these got missed. Note that this PR just copies the fixtures without adding `@enablePropagateDepsInHIR`. #31032 follows and actually enables the HIR-version of propagateScopeDeps to run. I split this out into two PRs to make snapshot differences easier to review, but also happy to merge
    
    Fixtures found from locally setting snap test runner to default to `enablePropagateDepsInHIR: 'enabled_baseline'` and forking fixtures files with different output.
    
    ghstack-source-id: 7d7cf41
    Pull Request resolved: #31030
    mofeiZ committed Sep 30, 2024
    Configuration menu
    Copy the full SHA
    943e45e View commit details
    Browse the repository at this point in the history
  2. [compiler][test fixtures] Add enablePropagateDepsInHIR to forked tests

    Annotates fixtures added in #31030 with `@enablePropagateDepsInHIR` to fork behavior (and commit snapshot differences)
    ghstack-source-id: e423e8c
    Pull Request resolved: #31031
    mofeiZ committed Sep 30, 2024
    Configuration menu
    Copy the full SHA
    1a77920 View commit details
    Browse the repository at this point in the history
  3. [compiler][hir-rewrite] Infer non-null props, destructure source

    Followup from #30894.
    This adds a new flagged mode `enablePropagateScopeDepsInHIR: "enabled_with_optimizations"`, under which we infer more hoistable loads:
    - it's always safe to evaluate loads from `props` (i.e. first parameter of a `component`)
    - destructuring sources are safe to evaluate loads from (e.g. given `{x} = obj`, we infer that it's safe to evaluate obj.y)
    - computed load sources are safe to evaluate loads from (e.g. given `arr[0]`, we can infer that it's safe to evaluate arr.length)
    
    ghstack-source-id: 32f3bb7
    Pull Request resolved: #31033
    mofeiZ committed Sep 30, 2024
    Configuration menu
    Copy the full SHA
    8c89fa7 View commit details
    Browse the repository at this point in the history
  4. [compiler][hir-rewrite] Cleanup Identifier -> IdentifierId

    Since removing ExitSSA, Identifier and IdentifierId should mean the same thing
    
    ghstack-source-id: 076cacb
    Pull Request resolved: #31034
    mofeiZ committed Sep 30, 2024
    Configuration menu
    Copy the full SHA
    58a3ca3 View commit details
    Browse the repository at this point in the history
  5. [compiler] repro for dep merging edge case (non-hir)

    Found when writing #31037, summary copied from comments:
    
    This is an extreme edge case and not code we'd expect any reasonable developer to write. In most cases e.g. `(a?.b != null ? a.b : DEFAULT)`, we do want to take a dependency on `a?.b`.
    
    I found this trying to come up with edge cases that break the current dependency + CFG merging logic. I think it makes sense to error on the side of correctness. After all, we still take `a` as a dependency if users write `a != null ? a.b : DEFAULT`, and the same fix (understanding the `<hoistable> != null` test expression) works for both. Can be convinced otherwise though!
    
    ghstack-source-id: cc06afd
    Pull Request resolved: #31035
    mofeiZ committed Sep 30, 2024
    Configuration menu
    Copy the full SHA
    5d12e9e View commit details
    Browse the repository at this point in the history
  6. [compiler][fixtures] Patch error-handling edge case in snap evaluator

    Fix edge case in which we incorrectly returned a cached exception instead of trying to rerender with new props.
    ghstack-source-id: 843fb85
    Pull Request resolved: #31082
    mofeiZ committed Sep 30, 2024
    Configuration menu
    Copy the full SHA
    2cbea24 View commit details
    Browse the repository at this point in the history
  7. [compiler] Renames and no-op refactor for next PR

    Rename for clarity:
    - `CollectHoistablePropertyLoads:Tree` -> `CollectHoistablePropertyLoads:PropertyPathRegistry`
        - `getPropertyLoadNode` -> `getOrCreateProperty`
        - `getOrCreateRoot` -> `getOrCreateIdentifier`
    - `PropertyLoadNode` -> `PropertyPathNode`
    
    Refactor to CFG joining logic for `CollectHoistablePropertyLoads`. We now write to the same set of inferredNonNullObjects when traversing from entry and exit blocks. This is more correct, as non-nulls inferred from a forward traversal should be included when computing the backward traversal (and vice versa). This fix is needed by an edge case in #31036
    
    Added invariant into fixed-point iteration to terminate (instead of infinite looping).
    
    ghstack-source-id: 1e8eb2d
    Pull Request resolved: #31036
    mofeiZ committed Sep 30, 2024
    Configuration menu
    Copy the full SHA
    c67e241 View commit details
    Browse the repository at this point in the history
  8. [Flight] Serialize Error Values (#31104)

    The idea is that the RSC protocol is a superset of Structured Clone.
    #25687 One exception that we left out was serializing Error objects as
    values. We serialize "throws" or "rejections" as Error (regardless of
    their type) but not Error values.
    
    This fixes that by serializing `Error` objects. We don't include digest
    in this case since we don't call `onError` and it's not really expected
    that you'd log it on the server with some way to look it up.
    
    In general this is not super useful outside throws. Especially since we
    hide their values in prod. However, there is one case where it is quite
    useful. When you replay console logs in DEV you might often log an Error
    object within the scope of a Server Component. E.g. the default RSC
    error handling just console.error and error object.
    
    Before this would just be an empty object due to our lax console log
    serialization:
    <img width="1355" alt="Screenshot 2024-09-30 at 2 24 03 PM"
    src="https://github.com/user-attachments/assets/694b3fd3-f95f-4863-9321-bcea3f5c5db4">
    After:
    <img width="1348" alt="Screenshot 2024-09-30 at 2 36 48 PM"
    src="https://github.com/user-attachments/assets/834b129d-220d-43a2-a2f4-2eb06921747d">
    
    TODO for a follow up: Flight Reply direction. This direction doesn't
    actually serialize thrown errors because they always reject the
    serialization.
    sebmarkbage authored Sep 30, 2024
    Configuration menu
    Copy the full SHA
    326832a View commit details
    Browse the repository at this point in the history

Commits on Oct 1, 2024

  1. [Flight] Serialize Server Components Props in DEV (#31105)

    This allows us to show props in React DevTools when inspecting a Server
    Component.
    
    I currently drastically limit the object depth that's serialized since
    this is very implicit and you can have heavy objects on the server.
    
    We previously was using the general outlineModel to outline
    ReactComponentInfo but we weren't consistently using it everywhere which
    could cause some bugs with the parsing when it got deduped on the
    client. It also lead to the weird feature detect of `isReactComponent`.
    It also meant that this serialization was using the plain serialization
    instead of `renderConsoleValue` which means we couldn't safely serialize
    arbitrary debug info that isn't serializable there.
    
    So the main change here is to call `outlineComponentInfo` and have that
    always write every "Server Component" instance as outlined and in a way
    that lets its props be serialized using `renderConsoleValue`.
    
    <img width="1150" alt="Screenshot 2024-10-01 at 1 25 05 AM"
    src="https://github.com/user-attachments/assets/f6e7811d-51a3-46b9-bbe0-1b8276849ed4">
    sebmarkbage authored Oct 1, 2024
    Configuration menu
    Copy the full SHA
    654e387 View commit details
    Browse the repository at this point in the history
  2. fix[react-devtools]: request hook initialization inside http server r…

    …esponse (#31102)
    
    Fixes #31100.
    
    There are 2 things:
    1. In #30987, we've introduced a
    breaking change: importing `react-devtools-core` is no longer enough for
    installing React DevTools global Hook. You need to call `initialize`, in
    which you may provide initial settings. I am not adding settings here,
    because it is not implemented, and there are no plans for supporting
    this.
    2. Calling `installHook` is not necessary inside `standalone.js`,
    because this script is running inside Electron wrapper (which is just a
    UI, not the app that we are debugging). We will loose the ability to use
    React DevTools on this React application, but I guess thats fine.
    hoxyq authored Oct 1, 2024
    Configuration menu
    Copy the full SHA
    40357fe View commit details
    Browse the repository at this point in the history
  3. chore[react-devtools]: add legacy mode error message to the ignore li…

    …st for tests (#31060)
    
    Without this, the console gets spammy whenever we run React DevTools
    tests against React 18.x, where this deprecation message was added.
    hoxyq authored Oct 1, 2024
    Configuration menu
    Copy the full SHA
    9ea5ffa View commit details
    Browse the repository at this point in the history
  4. chore[react-devtools]: drop legacy context tests (#31059)

    We've dropped the support for detecting changes in legacy Contexts in
    #30896.
    hoxyq authored Oct 1, 2024
    Configuration menu
    Copy the full SHA
    6e61258 View commit details
    Browse the repository at this point in the history
  5. Disable infinite render loop detection (#31088)

    We're seeing issues with this feature internally including bugs with
    sibling prerendering and errors that are difficult for developers to
    action on. We'll turn off the feature for the time being until we can
    improve the stability and ergonomics.
    
    This PR does two things:
    - Turn off `enableInfiniteLoopDetection` everywhere while leaving it as
    a variant on www so we can do further experimentation.
    - Revert #31061 which was a
    temporary change for debugging. This brings the feature back to
    baseline.
    jackpope authored Oct 1, 2024
    Configuration menu
    Copy the full SHA
    d8c90fa View commit details
    Browse the repository at this point in the history
  6. [Flight] Allow aborting encodeReply (#31106)

    Allow aborting encoding arguments to a Server Action if a Promise
    doesn't resolve. That way at least part of the arguments can be used on
    the receiving side. This leaves it unresolved in the stream rather than
    encoding an error.
    
    This should error on the receiving side when the stream closes but it
    doesn't right now in the Edge/Browser versions because closing happens
    immediately before we've had a chance to call `.then()` so the Chunks
    are still in pending state. This is an existing bug also in
    FlightClient.
    sebmarkbage authored Oct 1, 2024
    Configuration menu
    Copy the full SHA
    99c056a View commit details
    Browse the repository at this point in the history

Commits on Oct 2, 2024

  1. Define HostInstance type for React Native (#31101)

    ## Summary
    
    Creates a new `HostInstance` type for React Native, to more accurately
    capture the intent most developers have when using the `NativeMethods`
    type or `React.ElementRef<HostComponent<T>>`.
    
    Since `React.ElementRef<HostComponent<T>>` is typed as
    `React.AbstractComponent<T, NativeMethods>`, that means
    `React.ElementRef<HostComponent<T>>` is equivalent to `NativeMethods`
    which is equivalent to `HostInstance`.
    
    
    ## How did you test this change?
    
    ```
    $ yarn
    $ yarn flow fabric
    ```
    yungsters authored Oct 2, 2024
    Configuration menu
    Copy the full SHA
    459fd41 View commit details
    Browse the repository at this point in the history
Loading