Commit Graph

14505 Commits

Author SHA1 Message Date
Andrew Clark 8fcfdfff7e Scrape warning messages in CI (#22393)
There's a downstream workflow that runs the `print-warnings` command. We
can make it faster by scraping the warnings in CI and storing the
result as a build artifact.
2021-09-21 19:03:01 -07:00
Andrew Clark ba07042c86 Fix sizebot mistakenly detecting deleted files (#22394) 2021-09-21 18:55:47 -07:00
Andrew Clark d56947eb2c Increase polling threshold for publish-prereleases (#22392)
The publish-preleases command prints the URL of the publish workflow
so that you can visit the page and follow along.

But it can take a few seconds before the workflow ID is available, after
you create the pipeline. So the script polls the workflow endpoint
until it's available.

The current polling limit is too low so I increased it.

I also updated the error message to provide more info.
2021-09-21 18:43:59 -07:00
Luna Ruan 5b57bc6e31 [Draft] don't patch console during first render (#22308)
Previously, DevTools always overrode the native console to dim or supress StrictMode double logging. It also overrode console.log (in addition to console.error and console.warn). However, this changes the location shown by the browser console, which causes a bad developer experience. There is currently a TC39 proposal that would allow us to extend console without breaking developer experience, but in the meantime this PR changes the StrictMode console override behavior so that we only patch the console during the StrictMode double render so that, during the first render, the location points to developer code rather than our DevTools console code.
2021-09-21 15:00:11 -07:00
Andrew Clark cf07c3df12 Delete all but one build2 reference (#22391)
This removes all the remaining references to the `build2` directory
except for the CI job that stores the artifacts. We'll keep the
`build2` artifact until downstream scripts are migrated to `build`.
2021-09-21 13:15:41 -07:00
Andrew Clark bb0d069359 [build2 -> build] Local scripts
Update all our local scripts to use `build` instead of `build2`.

There are still downstream scripts that depend on `build2`, though, so
we can't remove it yet.
2021-09-21 15:14:09 -04:00
Andrew Clark 162bb8c978 [build -> build2] Sizebot 2021-09-21 15:07:16 -04:00
Andrew Clark 2375670a91 Delete unused CI jobs
These were replaced by the `build_combined` job.
2021-09-21 15:06:09 -04:00
Andrew Clark f35287dda4 [build2 -> build] -> download-build-artifacts 2021-09-21 13:47:40 -04:00
Andrew Clark e3c9cd9f41 Add COMMIT_SHA to build directory 2021-09-21 13:41:58 -04:00
Andrew Clark 0c81d347b6 Write artifacts to build instead of build2
Now that all the CI jobs have been migrated to the new build script,
we can start renaming the `build2` directory to `build`.

Since there are lots of scripts that reference `build2`, including
downstream scripts that live outside this repo, I'm going to keep
the `build2` directory around as a copy of `build`.

Then once all the references are updated, I will delete the copy.
2021-09-21 12:23:48 -04:00
Andrew Clark baff3f2005 Move build_devtools_and_process_artifacts (#22388)
This is the last CI job that needs to be migrated to the new workflow.
2021-09-21 08:51:51 -07:00
Andrew Clark 7c6049695f Move lint job to new, combined CI workflow (#22386)
* Move lint job to new, combined CI workflow

Moves the lint job our new, combined CI workflow.

After this, there is only one job remaining to be migrated. Then we
can delete the old workflow and build script.

* Remove "stable" CI workflow

This workflow is now empty so we can remove it
2021-09-21 08:16:26 -07:00
salazarm 4da03c9fbd useSyncExternalStore React Native version (#22367) 2021-09-21 11:07:56 -04:00
Bowen 48d475c9ed correct typos (#22294)
Co-authored-by: Bowen Li <bowen31337@gmail.com>
2021-09-21 11:05:41 -04:00
Andrew Clark fc57432966 Move DOM fixtures test job to main CI workflow (#22385)
Moves the RELEASE_CHANNEL_stable_yarn_test_dom_fixtures job to our new,
combined CI workflow.

After this, there are only two jobs remaining to be migrated. Then we
can delete the old workflow and build script.
2021-09-21 08:00:28 -07:00
Sebastian Silbermann cb6c619c07 Remove Fiber fields that were used for hydrating useMutableSource (#22368) 2021-09-20 21:12:30 +01:00
salazarm 64e70f82e9 [Fizz] add avoidThisFallback support (#22318) 2021-09-20 15:44:48 -04:00
38elements cbf6178ed3 Fix links in packages/react-devtools/README.md (#22356) 2021-09-20 15:10:29 -04:00
Konstantin Popov acf8ada4c0 Fix typo in types.js (react-devtools-shared) (#22299)
Fix typo:

becuase -> because
2021-09-20 15:09:59 -04:00
BIKI DAS c62d5831d3 react-devtools\OVERVIEW.md --> fixed typos (#22372) 2021-09-20 15:09:37 -04:00
Brian Vaughn 7e8fb98e14 Enabled enableProfilerChangedHookIndices feature flag for all builds (#22365) 2021-09-20 13:10:50 -04:00
Sebastian Silbermann 3ee7a004e5 devtools: Display actual ReactDOM API name in root type (#22363) 2021-09-20 11:44:21 -04:00
Andrew Clark 79b8fc6670 Implement getServerSnapshot in userspace shim (#22359)
* Convert useSES shim tests to use React DOM

Idea is that eventually we'll run these tests against an actual build of
React DOM 17 to test backwards compatibility.

* Implement getServerSnapshot in userspace shim

If the DOM is not present, we assume that we are running in a server
environment and return the result of `getServerSnapshot`.

This heuristic doesn't work in React Native, so we'll need to provide
a separate native build (using the `.native` extension). I've left this
for a follow-up.

We can't call `getServerSnapshot` on the client, because in versions of
React before 18, there's no built-in mechanism to detect whether we're
hydrating. To avoid a server mismatch warning, users must account for
this themselves and return the correct value inside `getSnapshot`.

Note that none of this is relevant to the built-in API that is being
added in 18. This only affects the userspace shim that is provided
for backwards compatibility with versions 16 and 17.
2021-09-20 08:32:13 -07:00
Andrew Clark 86b3e2461d Implement useSyncExternalStore on server (#22347)
Adds a third argument called `getServerSnapshot`.

On the server, React calls this one instead of the normal `getSnapshot`.
We also call it during hydration.

So it represents the snapshot that is used to generate the initial,
server-rendered HTML. The purpose is to avoid server-client mismatches.
What we render during hydration needs to match up exactly with what we
render on the server.

The pattern is for the server to send down a serialized copy of the
store that was used to generate the initial HTML. On the client, React
will call either `getSnapshot` or `getServerSnapshot` on the client as
appropriate, depending on whether it's currently hydrating.

The argument is optional for fully client rendered use cases. If the
user does attempt to omit `getServerSnapshot`, and the hook is called
on the server, React will abort that subtree on the server and
revert to client rendering, up to the nearest Suspense boundary.

For the userspace shim, we will need to use a heuristic (canUseDOM)
to determine whether we are in a server environment. I'll do that in
a follow up.
2021-09-20 08:31:02 -07:00
Brian Vaughn 57e4d6872f replace-fork: Cleanup after failure if no unstaged changes (#22364) 2021-09-20 11:10:17 -04:00
Andrew Clark 293059e52b replace-fork should not clear uncommitted changes (#22348)
The replace-fork script depends on ESLint to fix the reconciler imports
— `.old` -> `.new` or vice versa. If ESLint crashes, it can leave the
imports in an incorrect state.

As a convenience, @bvaughn updated the script to automatically run
`git checkout -- .` if the ESLint command fails. An unintended
consequence of the strategy is that if the working directory is not
clean, then any uncommitted changes will be lost.

We need a better strategy for this that prevents the accidental loss of
work. One option is to exit early if the working directory is not clean
before you run the script, though that affects the usability of
the script.

An ideal solution would reset the working directory back to whatever
state it was in before the script ran, perhaps by stashing all the
changes and restoring them if the script aborts.

Until we think of something better, I've commmented out the branch.
2021-09-20 10:07:25 -04:00
Andrew Clark 8209de2695 Delete useMutableSource implementation (#22292)
This API was replaced by useSyncExternalStore
2021-09-19 21:11:50 -07:00
Brian Vaughn f50ff357cf DevTools: Fix memory leak via alternate Fiber pointer (#22346) 2021-09-17 12:53:07 -04:00
Brian Vaughn bc9bb87c2b Clear performance marks after measuring (#22345) 2021-09-17 10:46:42 -04:00
Juan 1090ccd019 [DevTools] Enable hook names in standalone app (#22320) 2021-09-17 10:21:54 -04:00
Brian Vaughn f2fd1b80d5 Updated the utfDecodeString() method to avoid call stack exceeded error (#22330) 2021-09-17 09:52:52 -04:00
BIKI DAS b0803f255b VerticalScrollView -> fixed typos (#22341) 2021-09-17 09:05:09 -04:00
Ikko Ashimine a7da457e6b Scheduling profiler: Fix typo in View.js (#22337) 2021-09-17 09:04:51 -04:00
Juan a8cabb5648 [DevTools] Fix runtime error when inspecting an element times out (#22329) 2021-09-15 17:19:10 -04:00
Abhay Gupta e8feb11b62 Fixed issue for better bundles,chunks and workers name in devtools-extensions. (#22322) 2021-09-15 13:51:33 -04:00
Brian Vaughn f4ac680c7a Fixed broken build script --unsafe-partial flag (#22324)
This flag was broken due to a buggy race case in the ncp() command. The fix is amittedly a hack but improves on the existing behavior (of leaving the workspace in a broken state).
2021-09-15 13:32:09 -04:00
Dan Abramov 67222f044c [Experiment] Warn if callback ref returns a function (#22313) 2021-09-15 13:51:39 +01:00
Juan 50263d3273 [DevTools] Add initial APIs for logging instrumentation events under feature flag (#22276) 2021-09-14 11:10:24 -04:00
Ricky 263cfa6ecb [Experimental] Add useInsertionEffect (#21913) 2021-09-14 10:27:09 -04:00
Andrew Clark 806aaa2e21 [useSES shim] Import prefixed native API (#22310)
Until useSyncExternalStore is finalized, the shim should import the
prefixed version (unstable_useSyncExternalStore), which is available
in the experimental builds. That way our early testers can start
using it.
2021-09-13 21:55:18 -07:00
Andrew Clark fd5e01c2e0 [useSES/extra] Reuse old selection if possible (#22307)
When you pass an unmemoized selector to useSyncExternalStoreExtra, we
have to reevaluate it on every render because we don't know whether
it depends on new props.

However, after reevalutating it, we should still compare the result
to the previous selection with `isEqual` and reuse the old one if it
hasn't changed.

Originally I did not implement this, because if the selector changes due
to new props or state, the component is going to have to re-render
anyway. However, it's still useful to return a memoized selection
when possible, because it may be the input to a downstream memoization.

In the test I wrote, the example I chose is selecting a list of
items from the store, and passing the list as a prop to a memoized
component. If the list prop is memoized, we can bail out.
2021-09-13 14:26:41 -07:00
Andrew Clark 33226fadaa Check for store mutations before commit (#22290)
* [useSyncExternalStore] Remove extra hook object

Because we already track `getSnapshot` and `value` on the store
instance, we don't need to also track them as effect dependencies. And
because the effect doesn't require any clean-up, we don't need to track
a `destroy` function.

So, we don't need to store any additional state for this effect. We can
call `pushEffect` directly, and only during renders where something
has changed.

This saves some memory, but my main motivation is because I plan to use
this same logic to schedule a pre-commit consistency check. (See the
inline comments for more details.)

* Split shouldTimeSlice into two separate functions

Lanes that are blocking (SyncLane, and DefaultLane inside a blocking-
by-default root) are always blocking for a given root. Whereas expired
lanes can expire while the render phase is already in progress.

I want to check if a lane is blocking without checking whether it
expired, so I split `shouldTimeSlice` into two separate functions.

I'll use this in the next step.

* Check for store mutations before commit

When a store is read for the first time, or when `subscribe` or
`getSnapshot` changes, during a concurrent render, we have to check
at the end of the render phase whether the store was mutated by
an concurrent event.

In the userspace shim, we perform this check in a layout effect, and
patch up any inconsistencies by scheduling another render + commit.
However, even though we patch them up in the next render, the parent
layout effects that fire in the original render will still observe an
inconsistent tree.

In the native implementation, we can instead check for inconsistencies
right after the root is completed, before entering the commit phase. If
we do detect a mutaiton, we can discard the tree and re-render before
firing any effects. The re-render is synchronous to block further
concurrent mutations (which is also what we do to recover from tearing
bugs that result in an error). After the synchronous re-render, we can
assume the tree the tree is consistent and continue with the normal
algorithm for finishing a completed root (i.e. either suspend
or commit).

The result is that layout effects will always observe a consistent tree.
2021-09-13 08:07:46 -07:00
Konstantin Popov 86c7ca70a9 Fix link (#22296)
Fix link (branch master was renamed to main): 

master -> main
2021-09-12 11:09:53 -04:00
Ricky e73911e715 Clean up my "hard to read" code (#22295) 2021-09-11 15:05:54 -04:00
Brian Vaughn d2f08dd40d DevTools: Add missing param to fetchFromPage() (#22291) 2021-09-10 16:26:46 -04:00
Brian Vaughn 81db4eb1d1 Replaced network.onRequestFinished() caching with network.getHAR() (#22285)
Replaced network.onRequestFinished() caching with network.getHAR() so that we can avoid redundantly (pre) caching JavaScript content. In the event that the HAR log doesn't contain a match, we'll fall back to fetching from the Network (and hoping for a cache hit from that layer).

I've tested both internally (internal Facebook DEV server) and externally (Code Sandbox) and it seems like this approach results in cache hits, so long as DevTools is opened when the page loads. (Otherwise it falls back to fetch().)
2021-09-10 15:11:18 -04:00
salazarm 0fd195f295 update error message to include useLayoutEffect or useEffect on bad e… (#22279)
* update error message to include useLayoutEffect or useEffect on bad effect return

* Update packages/react-reconciler/src/ReactFiberCommitWork.new.js

Co-authored-by: Ricky <rickhanlonii@gmail.com>

* use existing import

Co-authored-by: Ricky <rickhanlonii@gmail.com>
2021-09-10 12:19:51 -04:00
Luna Ruan cb8a50619b [DevTools] Add React Devtools Extension Startup and File Structure to OVERVIEW.md (#22283) 2021-09-09 15:58:27 -07:00
Luna Ruan 43cf06daf9 [DevTools] Fix react-devtools-extension build error and react-devtools-inline's package.json (#22281) 2021-09-09 14:26:13 -07:00