Skip to content

[Bug]: Infinite loop on bad $LANG #2178

@nmattia

Description

@nmattia

This was originally report to jest, but it appears the issue is related to yargs. I've copied the text and adapted a bit from the original ticket.


Version

Jest: 26.0.24, 28.0.3
yargs: 16.0.4

Steps to reproduce

$ LANG=.UTF-8 npx jest --help
RangeError: Maximum call stack size exceeded
    at h (/Users/nicolas/proejct/.npm/_npx/b8d86e6551a4f492/node_modules/yargs/build/index.cjs:1:1423)
    at Xt.locale (/Users/nicolas/proejct/.npm/_npx/b8d86e6551a4f492/node_modules/yargs/build/index.cjs:1:36561)
    at Xt.[guessLocale] (/Users/nicolas/proejct/.npm/_npx/b8d86e6551a4f492/node_modules/yargs/build/index.cjs:1:46290)
    at Xt.locale (/Users/nicolas/proejct/.npm/_npx/b8d86e6551a4f492/node_modules/yargs/build/index.cjs:1:36664)
    at Xt.[guessLocale] (/Users/nicolas/proejct/.npm/_npx/b8d86e6551a4f492/node_modules/yargs/build/index.cjs:1:46290)
    at Xt.locale (/Users/nicolas/proejct/.npm/_npx/b8d86e6551a4f492/node_modules/yargs/build/index.cjs:1:36664)
    at Xt.[guessLocale] (/Users/nicolas/proejct/.npm/_npx/b8d86e6551a4f492/node_modules/yargs/build/index.cjs:1:46290)
    at Xt.locale (/Users/nicolas/proejct/.npm/_npx/b8d86e6551a4f492/node_modules/yargs/build/index.cjs:1:36664)
    at Xt.[guessLocale] (/Users/nicolas/proejct/.npm/_npx/b8d86e6551a4f492/node_modules/yargs/build/index.cjs:1:46290)
    at Xt.locale (/Users/nicolas/proejct/.npm/_npx/b8d86e6551a4f492/node_modules/yargs/build/index.cjs:1:36664)

Expected behavior

I expect jest to either warn, raise a proper error, or just continue if $LANG is bad.

Actual behavior

It appears to enter an infinite loop that blows the stack

Additional context

No response

Environment

$ npx envinfo --preset jest
Need to install the following packages:
  envinfo
Ok to proceed? (y) y

  System:
    OS: macOS 12.3.1
    CPU: (8) x64 Intel(R) Core(TM) i5-1038NG7 CPU @ 2.00GHz
  Binaries:
    Node: 16.15.0 - /nix/store/kwavq9kkqp2lb0lqx28ww3lkhi65dqbb-source/bin/node
    npm: 8.5.5 - /nix/store/kwavq9kkqp2lb0lqx28ww3lkhi65dqbb-source/bin/npm

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions