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

Maximum call stack size #712

Closed
4 tasks done
fabiankranewitter opened this issue Sep 30, 2021 · 2 comments
Closed
4 tasks done

Maximum call stack size #712

fabiankranewitter opened this issue Sep 30, 2021 · 2 comments
Labels
good first issue Good for newcomers Type: Bug Bug or Bug fixes

Comments

@fabiankranewitter
Copy link
Contributor

fabiankranewitter commented Sep 30, 2021

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

@fabiankranewitter fabiankranewitter added the Status: Review Needed Request for review comments label Sep 30, 2021
kazupon added a commit that referenced this issue Oct 1, 2021
@kazupon
Copy link
Member

kazupon commented Oct 1, 2021

Thank you for your reporting!

i've reproduced this issue in my environment.

We can check the repro/tokenizer-max-call-stack branch.
https://github.com/intlify/vue-i18n-next/blob/3729ee00b30353349b65e1f29d172d62e26ea7b8/packages/message-compiler/test/tokenizer.test.ts#L104-L119

We'll try to fix it.

@kazupon kazupon added good first issue Good for newcomers Priority: Medium Type: Bug Bug or Bug fixes and removed Status: Review Needed Request for review comments labels Oct 1, 2021
kazupon added a commit that referenced this issue Oct 2, 2021
* add #712 reproduction case

* remove unnecesary code

* Rewrite readText as an iterative version
Fix warning in test

Co-authored-by: kazuya kawaguchi <kawakazu80@gmail.com>
@kazupon
Copy link
Member

kazupon commented Oct 2, 2021

Close with #713
I'm going to release v9.2.0-beta.11

@kazupon kazupon closed this as completed Oct 2, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
good first issue Good for newcomers Type: Bug Bug or Bug fixes
Projects
None yet
Development

No branches or pull requests

2 participants