Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(rollup): use copySync instead of async copy #4001

Merged
merged 6 commits into from
Aug 17, 2022

Conversation

n8agrin
Copy link
Contributor

@n8agrin n8agrin commented Aug 15, 2022

yarn playground:new was generating random errors related to unlinking/deleting files that did not exist. File copying was using an asynchronous method to move files into playground directories.

This change makes the copy/move operation synchronous and eliminates race conditions, ensuring yarn playground:new always succeeds.

`yarn playground:new` was generating random errors related to unlinking/deleting files that did not exist. File copying was using an asynchronous method to move files into playground directories.

This change makes the copy/move operation synchronous and eliminates race conditions, ensuring `yarn playground:new` always succeeds.
@changeset-bot
Copy link

changeset-bot bot commented Aug 15, 2022

⚠️ No Changeset found

Latest commit: f302f07

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

This PR includes no changesets

When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

Click here to learn what changesets are, and how to add one.

Click here if you're a maintainer who wants to add a changeset to this PR

@remix-cla-bot
Copy link
Contributor

remix-cla-bot bot commented Aug 15, 2022

Hi @n8agrin,

Welcome, and thank you for contributing to Remix!

Before we consider your pull request, we ask that you sign our Contributor License Agreement (CLA). We require this only once.

You may review the CLA and sign it by adding your name to contributors.yml.

Once the CLA is signed, the CLA Signed label will be added to the pull request.

If you have already signed the CLA and received this response in error, or if you have any questions, please contact us at hello@remix.run.

Thanks!

- The Remix team

@remix-cla-bot
Copy link
Contributor

remix-cla-bot bot commented Aug 15, 2022

Thank you for signing the Contributor License Agreement. Let's get this merged! 🥳

Copy link
Member

@MichaelDeBoey MichaelDeBoey left a comment

Choose a reason for hiding this comment

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

I don't think this changes anything tbh, as we're awaiting for the sync to be finished before we continue (just like we would use the synchronous function) 🤔

@MichaelDeBoey MichaelDeBoey changed the title Use copySync in playground:new to avoid race condition errors when generating new playgrounds fix(rollup): use copySync instead of async copy Aug 15, 2022
@n8agrin
Copy link
Contributor Author

n8agrin commented Aug 15, 2022

@MichaelDeBoey regarding this not changing anything, a trivial repro is to checkout a new clone of remix and run yarn playground:new. On my machine that frequently produces errors like the following:

packages/remix-dev/server-build.ts → build/node_modules/@remix-run/dev, build/node_modules/@remix-run/dev/dist...
[!] (plugin copy-to-remix-playground) Error: ENOENT: no such file or directory, unlink '/Users/nate/Projects/remix-two/playground/playground-1660456168247/node_modules/@remix-run/dev/dist/cli/migrate/migrations/replace-remix-imports/transform/index.js'
Error: ENOENT: no such file or directory, unlink '/Users/nate/Projects/remix-two/playground/playground-1660456168247/node_modules/@remix-run/dev/dist/cli/migrate/migrations/replace-remix-imports/transform/index.js'

error Command failed with exit code 1.
info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.
node:internal/errors:841
  const err = new Error(message);
              ^

Error: Command failed: yarn rollup -c
    at checkExecSyncError (node:child_process:828:11)
    at execSync (node:child_process:899:15)
    at createNewProject (/Users/nate/Projects/remix-two/scripts/playground/new.js:46:3) {
  status: 1,
  signal: null,
  output: [ null, null, null ],
  pid: 9794,
  stdout: null,
  stderr: null
}
error Command failed with exit code 1.
info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.

I agree that in theory the await fse.copy gesture should prevent this, and I didn't dig into the internals of fs-extra, but changing copy to copySync completely eliminates the issue for me.

@jacob-ebey
Copy link
Member

@MichaelDeBoey I said to put this PR up. It's something I've ran into locally quite a bit and I address it with the above solution. I'm honestly not sure why async ops are breaking here, but they are.

@n8agrin n8agrin requested a review from MichaelDeBoey August 15, 2022 18:56
Copy link
Member

@kentcdodds kentcdodds left a comment

Choose a reason for hiding this comment

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

Seems fine 👍

@kentcdodds
Copy link
Member

kentcdodds commented Aug 17, 2022

Just sitting like this forever. Even after a refresh 🤦‍♂️

image

@kentcdodds kentcdodds merged commit 5e44bf0 into remix-run:dev Aug 17, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants