Skip to content

County method used with uniqueArray helper crashes faker. #2207

Description

@jviall

Pre-Checks

Describe the bug

Using the county method with the uniqueArray completely crashes not just faker but my entire runtime. In my case, I discovered it in a React + Storybook project, where I switched from using country to using county, and my entire browser became unresponsive.

Attached is a stackblitz (based on the one linked in the docs), that does the same thing, comparing the country method to the county method using the uniqueArray helper, where generating some unique countries works fine, but counties do not.

Minimal reproduction code

https://stackblitz.com/edit/faker-js-demo-rqnnk9?file=index.ts

Additional Context

I personally use faker in a Vite + Storybook + React environment, using ES Modules targeting an ESNext build. However, it is reproduce-able (as shown in the stackblitz) in plain JS modules.

Environment Info

System:
    OS: macOS 13.2.1
    CPU: (10) arm64 Apple M2 Pro
    Memory: 63.45 MB / 32.00 GB
    Shell: 5.8.1 - /bin/zsh
  Binaries:
    Node: 18.16.0 - ~/Library/Caches/fnm_multishells/22781_1678232715369/bin/node
    Yarn: 3.4.1 - /usr/local/bin/yarn
    npm: 9.5.1 - ~/Library/Caches/fnm_multishells/22781_1678232715369/bin/npm
  Browsers:
    Chrome: 114.0.5735.106
    Firefox: 112.0.2
    Safari: 16.3
  npmPackages:
    @faker-js/faker: 8.0.2 => 8.0.2

Which module system do you use?

  • CJS
  • ESM

Used Package Manager

pnpm

Metadata

Metadata

Assignees

No one assigned

    Labels

    c: bugSomething isn't workinghas workaroundWorkaround provided or linkedm: helpersSomething is referring to the helpers modules: acceptedAccepted feature / Confirmed bug

    Fields

    No fields configured for issues without a type.

    Projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions