Commit Graph

13770 Commits

Author SHA1 Message Date
Andrew Clark
00a5b08e24 Remove PassiveStatic optimization
Passive flags are a new concept that is tricky to get right. We've
already found two bugs related to PassiveStatic. Let's remove this
optimization for now, and add it back once the main part of the effects
refactor lands.
2020-12-18 11:31:35 -06:00
Andrew Clark
a6329b1050 Don't clear static flags in resetWorkInProgress
Fixes the regression test added in #20433
2020-12-18 11:30:20 -06:00
Andrew Clark
1cf59f34b8 Convert passive unmount phase to tree traversal 2020-12-18 11:29:38 -06:00
Andrew Clark
ab29695a05 Defer more field detachments to passive phase
This allows us to use those fields during passive unmount traversal.
2020-12-18 11:28:49 -06:00
Andrew Clark
d37d7a4bb4 Convert passive mount phase to tree traversal 2020-12-18 11:27:53 -06:00
Andrew Clark
19e15a3986 Add PassiveStatic to trees with passive effects
Indicates that a tree needs passive clean-up on deletion.
2020-12-18 11:27:08 -06:00
Andrew Clark
ff17fc176f Don't clear other flags when adding Deletion
Same as #20398 but for Deletions. There's no new regression test, but in
the effects refactor, existing tests will fail without this.
2020-12-17 16:31:50 -06:00
Ricky
5687864eb7 Add back disableSchedulerTimeoutInWorkLoop flag (#20482)
* Add back enableSchedulerTimeoutInWorkLoop flag

* Nvm, keep it as disableSchedulerTimeoutInWorkLoop
2020-12-17 17:17:23 -05:00
Luna Ruan
9f338e5d77 clone json obj in react native flight client host config parser (#20474)
As per Seb's comment in #20465, we need to do the same thing in React Native as we do in Relay.

When `parseModel` suspends because of missing dependencies, it will exit and retry to parse later. However, in the relay implementation, the model is an object that we modify in place when we parse it, so when we we retry, part of the model might be parsed already into React elements, which will error because the parsing code expect a Flight model. This diff clones instead of mutating the original model, which fixes this error.
2020-12-16 11:53:51 -08:00
Luna Ruan
4e62fd2712 clone json obj in relay flight client host config parser (#20465)
When `parseModel` suspends because of missing dependencies, it will exit and retry to parse later. However, in the relay implementation, the model is an object that we modify in place when we parse it, so when we we retry, part of the model might be parsed already into React elements, which will error because the parsing code expect a Flight model. This diff clones instead of mutating the original model, which fixes this error.
2020-12-15 15:33:54 -08:00
Oliver Lassen
604bbcd87d [devtools] Increase the clickable area of the prop value (#20428) 2020-12-14 16:23:26 -05:00
Dan Abramov
070372cde2 [Flight] Fix webpack watch mode issue (#20457) 2020-12-14 15:50:20 +00:00
Dan Abramov
0f80dd1484 [Flight] Support concatenated modules in Webpack plugin (#20449)
* Extract recordModule

* Add support for concatenated modules
2020-12-13 17:44:59 +00:00
Dan Abramov
daf38ecdfc [Flight] Use lazy reference for existing modules (#20445) 2020-12-11 22:45:18 +00:00
Andrew Clark
3f9205c333 Regression test: SuspenseList causes lost unmount (#20433)
@sebmarkbage reminded me that the complete phase of SuspenseList
will sometimes enter the begin phase of the children without calling
`createWorkInProgress` again, instead calling `resetWorkInProgress`.

This was raised in the context of considering whether #20398 might
have accidentally caused a SuspenseList bug. (I did look at this code
at the time, but considering how complicated SuspenseList is it's not
hard to imagine that I made a mistake.)

Anyway, I think that PR is fine; however, reviewing it again did lead me
to find a different bug. This new bug is actually a variant of the bug
fixed by #20398.

`resetWorkInProgress` clears a fiber's static flags. That's wrong, since
static flags -- like PassiveStatic -- are meant to last the lifetime of
the component.

In more practical terms, what happens is that if a direct child of
SuspenseList contains a `useEffect`, then SuspenseList will cause the
child to "forget" that it contains passive effects. When the child
is deleted, its unmount effects are not fired :O

This is the second of this type of bug I've found, which indicates to me
that it's too easy to accidentally clear static flags.

Maybe we should only update the `flags` field using helper functions,
like we do with `lanes`.

Or perhaps we add an internal warning somewhere that detects when a
fiber has different static flags than its alternate.
2020-12-11 08:38:49 -08:00
Sebastian Markbåge
cdfde3ae11 Always rethrow original error when we replay errors (#20425)
We replay errors so you can break on paused exceptions. This is done in
the second pass so that the first pass can ignore suspense.

Originally this threw the original error. For suppression purposes
we copied the flag onto the original error.

f1dc626b29/packages/react-reconciler/src/ReactFiberScheduler.old.js (L367-L369)

During this refactor it changed to just throw the retried error:

https://github.com/facebook/react/pull/15151

We're not sure exactly why but it was likely just an optimization or
clean up.

So we can go back to throwing the original error. That helps in the case
where a memoized function is naively not rethrowing each time such as
in Node's module system.

Unfortunately this doesn't fix the problem fully.
Because invokeGuardedCallback captures the error and logs it to the browser.
So you still end up seeing the wrong message in the logs.

This just fixes so that the error boundary sees the first one.
2020-12-10 05:50:41 -08:00
Dan Abramov
b15d6e93e7 [Flight] Make PG and FS server-only (#20424)
* Make react-fs server-only

* Make react-pg server-only
2020-12-10 06:15:37 +00:00
Dan Abramov
40ff2395e4 [Flight] Prevent non-Server imports of aliased Server entrypoints (#20422)
* [Flight] Prevent non-Server imports of aliased Server entrypoints

* Fix Flow + await

* Tighten the types
2020-12-10 03:55:38 +00:00
Dan Abramov
94aa365e3a [Flight] Fix webpack plugin to use chunk groups (#20421) 2020-12-10 03:03:53 +00:00
Dan Abramov
842ee367e6 [Flight] Rename the shared entry point (#20420)
* [Flight] Rename the shared entry point

* Shared
2020-12-10 02:14:50 +00:00
Dan Abramov
dbf40ef759 Put .server.js at the end of bundle filenames (#20419)
* Put .server.js at the end of bundle filenames

* Client too
2020-12-09 22:47:17 +00:00
Dan Abramov
03126dd087 [Flight] Add read-only fs methods (#20412)
* Don't allocate the inner cache unnecessarily

We only need it when we're asking for text. I anticipate I'll want to avoid allocating it in other methods too when it's not strictly necessary.

* Add fs.access

* Add fs.lstat

* Add fs.stat

* Add fs.readdir

* Add fs.readlink

* Add fs.realpath

* Rename functions to disambiguate two caches
2020-12-09 21:46:50 +00:00
Brian Vaughn
b51a686a93 Turn on double effects for www test renderer (#20416) 2020-12-09 11:46:18 -08:00
Brian Vaughn
56a632adb6 Double Invoke Effects in __DEV__ (in old reconciler fork) (#20415)
We originally added a new DEV behavior of double-invoking effects during mount to our new reconciler fork in PRs #19523 and #19935 and later refined it to only affect modern roots in PR #20028. This PR adds that behavior to the old reconciler fork with a small twist– the behavior applies to StrictMode subtrees, regardless of the root type.

This commit also adds a few additional tests that weren't in the original commits.
2020-12-09 14:18:26 -05:00
togami2864
1a24223375 fixed typo (#20351) 2020-12-09 09:26:12 -05:00
Dan Abramov
a233c9e2aa Rename internal cache helpers (#20410) 2020-12-09 02:57:14 +00:00
Dan Abramov
6a4b12b81c [Flight] Add rudimentary FS binding (#20409)
* [Flight] Add rudimentary FS binding

* Throw for unsupported

* Don't mess with hidden class

* Use absolute path as the key

* Warn on relative and non-normalized paths
2020-12-09 02:37:29 +00:00
Andrew Clark
7659949d65 Clear deletions in detachFiber (#20401)
This was added in a later step of the refactor but since `deletions`
array already landed, clearing it should, too.

I think it's unlikely that this causes GC problems but worth
adding anyway.
2020-12-08 17:13:20 -08:00
Dan Abramov
b9680aef7d Cache react-fetch results in the Node version (#20407) 2020-12-08 22:37:24 +00:00
inokawa
cdae31ab8e Fix typo (#20279) 2020-12-08 10:40:35 -05:00
Hollow Man
51a7cfe210 Fix typo (#20300)
Signed-off-by: Hollow Man <hollowman@hollowman.ml>
2020-12-08 10:40:23 -05:00
Sam Zhou
373b297c55 fix: Fix typo in react-reconciler docs (#20284)
peristent -> persistent
2020-12-08 10:40:05 -05:00
Dan Abramov
1b5ca99063 Fix module ID deduplication (#20406) 2020-12-08 13:19:59 +00:00
Sebastian Markbåge
5fd9db732d [Flight] Rename react-transport-... packages to react-server-... (#20403)
* Move files

* Update paths

* Rename import variables

* Rename /server to /writer

This is mainly because "React Server Server" is weird so we need another
dimension.

* Use "react-server" convention to enforce that writer is only loaded in a server
2020-12-08 08:08:57 -05:00
Sebastian Markbåge
ce40f1dc2f Use assets API + writeToDisk instead of directly writing to disk (#20402) 2020-12-07 17:54:28 -08:00
Dan Abramov
0512cd6a26 Bump fixture dependency versions (#20397)
* Bump all versions

* Switch to CJS mode

* Revert "Switch to CJS mode"

This reverts commit b3c4fd92dcef6ecb4116fc66f674ae88aad3c582.

* Fix ES mode

* Add nodemon to restart the server on edits

* Ignore /server/ from compilation
2020-12-08 01:23:49 +00:00
Andrew Clark
b66ae09b6e Track subtreeFlags et al with bubbleProperties
Original PR: #19836
2020-12-07 15:50:43 -06:00
Andrew Clark
de75315d7e Track deletions using an array on the parent
Adds back the `deletions` array and uses it in the commit phase.

We use a trick where the first time we hit a deletion effect, we commit
all the deletion effects that belong to that parent. This is an
incremental step away from using the effect list and toward a DFS +
subtreeFlags traversal.

This will help determine whether the regression is caused by, say,
pushing the same fiber into the deletions array multiple times.
2020-12-07 15:11:25 -06:00
Andrew Clark
1377e465dd Add Placement bit without removing others (#20398)
When scheduling a Placement effect, we should add the Placement bit
without resetting the others.

In the old fork, there are no flags to reset, anyway, since by the
time we reach the child reconciler, the flags will have already been
reset.

However, in the effects refactor, "static" flags are not reset, so this
can actually manifest as a bug. See #20285 for a regression test.
2020-12-07 13:07:28 -08:00
Andrew Clark
18d7574ae2 Remove catch from Scheduler build (#20396)
Makes debugging errors harder.

In this case, we can use `finally` instead.
2020-12-07 11:10:53 -08:00
Sebastian Markbåge
30dfb86025 [Flight] Basic scan of the file system to find Client modules (#20383)
* Basic scan of the file system to find Client modules

This does a rudimentary merge of the plugins. It still uses the global
scan and writes to file system.

Now the plugin accepts a search path or a list of referenced client files.
In prod, the best practice is to provide a list of files that are actually
referenced rather than including everything possibly reachable. Probably
in dev too since it's faster.

This is using the same convention as the upstream ContextModule - which
powers the require.context helpers.

* Add neo-async to dependencies
2020-12-07 12:10:18 -05:00
Brian Vaughn
dd16b78990 Tweaked DevTools build command slightly 2020-12-07 10:10:43 -05:00
Brian Vaughn
4053c76b7d Add more DevTools tests for React.Lazy (#20380) 2020-12-06 09:10:15 -05:00
Sebastian Markbåge
0db61a08be Fix Flight Prod Fixture (#20382)
* Don't use async/await

Babel transpilation fails for some reason in prod.

* Set up production runner command

Uses python because meh. Just to show it's static.

* Use build folder in prod
2020-12-04 18:00:57 -08:00
Brian Vaughn
3a8c04e3b2 React DevTools 4.10.0 -> 4.10.1 2020-12-04 16:54:14 -05:00
Brian Vaughn
f160547f47 React DevTools 4.10.0 -> 4.10.1 2020-12-04 16:43:13 -05:00
Dan Abramov
9b8060041b Error when the number of parameters to a query changes (#20379) 2020-12-04 20:11:00 +00:00
Dan Abramov
60e4a76fa8 [Flight] Add rudimentary PG binding (#20372)
* [Flight] Add rudimentary PG binding

* Use nested Maps for parameters

* Inline and fix Flow
2020-12-04 17:27:33 +00:00
Andrew Clark
88ef95712d Fork ReactFiberLane (#20371)
This wasn't forked previously because Lane and associated types are
opaque, and they leak into non-reconciler packages. So forking the type
would also require forking all those other packages.

But I really want to use the reconciler fork infra for lanes changes.
So I made them no longer opaque.

Another possible solution would be to add separate `new` and `old`
fields to the Fiber type, like I did when migrating from expiration
times. But that seems so excessive. This seems fine.

But we should still treat them like they're opaque and only do lanes
manipulation in the ReactFiberLane module. At least until the model
stabilizes more. We'll just need to enforce this with discipline
instead of with the type system.
2020-12-04 10:54:09 -06:00
Arindam Pradhan
e9860d426f fixed: typo in react-devtools/README.md Websocked -> Websocket (#20376) 2020-12-04 09:59:17 -05:00