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

Using untoggledComponent with MemoryAdapter in a vitest unit test causes OOM from re-render loop #1771

Open
ghost opened this issue Jun 8, 2023 · 1 comment

Comments

@ghost
Copy link

ghost commented Jun 8, 2023

Describe the bug
Using the untoggledComponent prop of the ToggleFeature component with MemoryAdapter appears to cause an infinite re-render loop resulting in an OOM Error in a vitest unit test.

We are using MemoryAdapter with a set of defaultFlags to provide "mock flags" to the unit tests, through a "mock" ConfigureFlopFilp provider.

To Reproduce
Steps to reproduce the behavior:

  1. Given a ConfigureFlopFilp provider using MemoryAdapter and a set of defaultFlags,
  2. Then when using the untoggledComponent prop of the ToggleFeature component such that we return a component from the toggledComponent prop, and return () => null from the untoggledComponent prop,
  3. That causes an infinite re-render loop during a run of unit tests with vitest, and eventually exits with an OOM Error.
  4. While using the same ToggleFeature in normal execution outside of test operates as expected.

Expected behavior
We should be able to use the same ToggleFeature with an untoggledComponent and a null/empty toggledComponent in the normal application and in a mocked unit test with the same result, and no infinite re-render/OOM.

Screenshots
Screenshot 2023-06-08 at 12 43 35 PM

Additional context
Replacing the ToggleFeature using untoggledComponent and a null/empty toggledComponent, with the use of the useFeatureToggle(flagName) hook and a conditional render of the untoggled component ovoids this OOM error. So it appears that there's some difference of behavior between the hook and the ToggleFeature component.

@tdeekens
Copy link
Owner

tdeekens commented Jun 9, 2023

Thanks for reporting this issue in great detail. I'll try to make room to investigate it. If you find out more and can even propose a fix please don't hesitate to do so.

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

No branches or pull requests

1 participant