Skip to content

Maximum call stack size #712

@fabiankranewitter

Description

@fabiankranewitter

Reporting a bug?

Vue-i18n crashes when a long text is to be displayed. The problem is that in message-compiler/src/tokenizer.ts a recursion is used in the function readText. If several thousand characters are displayed, for example 20000 in my case, there is a stack overflow because the function calls itself so often. It should be easy to rewrite this function iteratively.

Stacktrace:
Uncaught RangeError: Maximum call stack size exceeded at charAt (message-compiler.esm-bundler.js?f92f:80) at Object.currentPeek (message-compiler.esm-bundler.js?f92f:82) at fn (message-compiler.esm-bundler.js?f92f:329) at isTextStart (message-compiler.esm-bundler.js?f92f:357) at fn (message-compiler.esm-bundler.js?f92f:431) at fn (message-compiler.esm-bundler.js?f92f:448) at fn (message-compiler.esm-bundler.js?f92f:448) at fn (message-compiler.esm-bundler.js?f92f:448) at fn (message-compiler.esm-bundler.js?f92f:448) at fn (message-compiler.esm-bundler.js?f92f:448)

Expected behavior

Text should be rendered and no exception should be thrown.

Reproduction

Insert a text with several thousand characters (e.g. 20000) into the language file and display it on the website.

System Info

System:
    OS: Linux 5.11
    CPU: (8) x64 Intel(R) Core(TM) i7-4770K CPU @ 3.50GHz
    Memory: 16.55 GB / 31.30 GB
    Container: Yes
    Shell: 5.1.4 - /bin/bash
  Binaries:
    Node: 12.21.0 - /usr/bin/node
    Yarn: 1.22.15 - /usr/local/bin/yarn
    npm: 7.24.1 - /usr/local/bin/npm

Screenshot

No response

Additional context

No response

Validations

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions