Fixed broken build script --unsafe-partial flag #22324
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Resolves #22323
The following example command sequence will fail:
The above sequence should work but instead fails with one of the two errors below:
This leaves the repo in a broken state (tests won't run, DevTools test shell will crash, etc).
These errors are thrown because this function prematurely resolves:
react/scripts/rollup/utils.js
Lines 10 to 24 in 67222f0
Either before the
package.json
file has been copied, or after it has been copied (but while its contents are still empty).This causes the subsequent read of
package.json
to throw:react/scripts/rollup/packaging.js
Lines 145 to 148 in 67222f0
The error above can be verified by adding logging to the
asyncTopyTo
method:I'm able to "fix" this issue by introducing a small amount of delay, e.g.
But that's pretty hacky and fragile.
I evaluated replacing
ncp
with some other alternatives:copyfiles
- Bad documentation.cpx
– Similar interface, seems to have the exact same race case problem asncp
recursively-copy
- Worked locally but broke CI (see Rollup build script --unsafe-partial flag is broken #22323).Seems like this is perhaps related to AvianFlu/ncp#127
With this change, I am able to successfully run the command shown above: