mirror of
https://github.com/invoke-ai/InvokeAI.git
synced 2026-02-13 17:14:56 -05:00
Fix an issue in certain browsers/builds causing a runtime error. A zod enum has a .options property, which is an array of all the options for the enum. This is handy for when you need to derive something from a zod schema. In this case, we represented the possible focus regions in the zod enum, then derived a mapping of region names to set of target HTML elements. Why isn't important, but suffice to say, we were using the .options property for this. But actually, we were using .options.values(), then calling .reduce() on that. An array's .values() method returns an _array iterator_. Array iterators do not have .reduce() methods! Except, apparently in some environments they do - it depends on the JS engine and whether or not polyfills for iterator helpers were included in the build. Turns out my dev environment - and most user browsers - do provide .reduce(), so we didn't catch this error. It took a large deployment and error monitoring to catch it. I've refactored the code to totally avoid deriving data from zod in this way.