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

Add missing NODE_ENV checks to ComboBox #3487

Closed

Conversation

panusoi
Copy link

@panusoi panusoi commented Sep 24, 2024

This PR fixes an issue where a virtualized ComboBox crashed if there was global process variable without env property. The issue was caused by a missing process.env.NODE_ENV === 'test' check which caused the branch to end up in the released version.

Copy link

vercel bot commented Sep 24, 2024

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
headlessui-react ✅ Ready (Inspect) Visit Preview 💬 Add feedback Sep 24, 2024 4:55pm
headlessui-vue ✅ Ready (Inspect) Visit Preview 💬 Add feedback Sep 24, 2024 4:55pm

RobinMalfait added a commit that referenced this pull request Sep 27, 2024
)

This PR is a different approach compared to #3487. 

Instead of checking whether we are in a test environment (specifically
in a Jest environment), I think we can just get rid of the check
entirely and use the virtualizer in all environments.

This will remove an unnecessary check for `process` being available and
gets rid of `process` entirely. It also fixes an issue that #3487 tries
to solve where `process` is available, but `process.env` is not.

Closes: #3487
@RobinMalfait
Copy link
Member

Hey!

Thank you for the PR, I did implement an alternative by getting rid of the process entirely. We already checked whether process was available or not. I do have a question, in what environment was process available but process.env is not?

Either way, we got rid of the entire check in #3495 and will be available in the next release.

You can already try it using:

  • npm install @headlessui/react@insiders.
  • npm install @headlessui/vue@insiders.

Thanks again for your initial work!

@panusoi
Copy link
Author

panusoi commented Sep 27, 2024

Hi,

I encountered this issue when I was running the Cypress component tests. The environment was Typescript + Cypress + React + Vite. For some reason Cypress exposes an empty process object.

I ran my tests with @headlessui/react@insiders and everything works great. Thanks!

@panusoi panusoi deleted the add-missing-node-env-checks branch September 27, 2024 13:10
@RobinMalfait
Copy link
Member

@panusoi Aha good to know, thanks for the info. Glad it's working with the insiders build!

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.

2 participants