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: Windows development #7925

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open

Fix: Windows development #7925

wants to merge 2 commits into from

Conversation

lukpsaxo
Copy link
Contributor

Closes #7924

✅ Pull Request Checklist:

  • Included link to corresponding React Spectrum GitHub Issue.
  • Added/updated unit tests and storybook for this change (for new code or code which already has tests).
  • Filled out test instructions.
  • Updated documentation (if it already exists for this component).
  • Looked at the Accessibility Practices for this feature - Aria Practices

📝 Test Instructions:

I know the core team is all on Mac - maybe check yarn test still works there.

Part of the fix taken from this suggestion: #2429 (comment)

🧢 Your Project:

Saxo Bank

@lukpsaxo lukpsaxo closed this Mar 13, 2025
@lukpsaxo lukpsaxo reopened this Mar 13, 2025
@LFDanLu
Copy link
Member

LFDanLu commented Mar 14, 2025

Thanks for the PR! I just tested it locally on my Windows machine and confirmed that the tests actually run now, but I seem to get a bunch of errors related missing translations due to the i18n files not being properly parsed or something. Pretty new to developing to Windows so I'll poke around and see if I patch a couple of things, but just wanted to know what configuration you are running on your end.

@lukpsaxo
Copy link
Contributor Author

I only get tests working enough to test my other PR - but I'll see if the other failing tests are easy fixes.

@lukpsaxo
Copy link
Contributor Author

Ok, I got it working better. It will now fail a little bit the first run and then be ok.

long winded explanation:

Unfortunately this code is unreliable in windows:

function writeCacheFile(cacheFile, res) {
  // If cache file already exists, return it.
  if (fs.existsSync(cacheFile)) {
    return cacheFile;
  }

  // Otherwise, write it atomically to avoid race conditions between threads/processes.
  let tmpFile = cacheFile + '.' + process.pid + (threadId != null ? '.' + threadId : '');
  fs.writeFileSync(tmpFile, res);
  fs.renameSync(tmpFile, cacheFile);
  return cacheFile;
}

There is a package - write-file-atomic - which is better but still fails in windows sometimes. In fact we have to have a patched version of jest to deal with this :/

jestjs/jest#11104 (comment)

and the only way to fix this 100% for windows is to make the resolver async or change the approach - for instance I would make this a transform and not done as part of the resolution, which would fix the problem.

But thats a bigger change. I can live with tests failing the first time.

LFDanLu
LFDanLu previously approved these changes Mar 17, 2025
Copy link
Member

@LFDanLu LFDanLu left a comment

Choose a reason for hiding this comment

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

Thanks for the updates, confirmed that the tests are passing on the second run on windows and that things seems to run fine on MacOS. Will have to dig into patching writeCacheFile later but I think this is fine for now, will need to leave a note in the docs/FAQ

@lukpsaxo
Copy link
Contributor Author

I will wait for:

#7933

to be merged

and then rebase this (unless you prefer to go ahead and merge and rebase #7933)

@lukpsaxo
Copy link
Contributor Author

rebased - ready for review and merge

@lukpsaxo
Copy link
Contributor Author

any chance of a second approval and merge?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Development is broken on windows
2 participants