robisim74 / qwik-speak

Translate your Qwik apps into any language
https://robisim74.gitbook.io/qwik-speak/
MIT License
133 stars 15 forks source link

Qwik-speak-extract: Maximum call stack exceeded #113

Closed genox closed 9 months ago

genox commented 9 months ago

Hi,

Had a bit of downtime and tried to test the new setup. While trying to extract the strings I got the following error on node 20.11.0:

Qwik Speak Extract
extracting translation...
file:///....../node_modules/qwik-speak/extract/index.js:14
  const p = (a) => (e = l, { type: a, value: O(), position: { start: e, end: l } }), P = (a) => {
                                                                                         ^

RangeError: Maximum call stack size exceeded

This happens both with --autoKeys enabled or disabled.

However, running the npm run script in this repository (e.g. checking out this repository here and running the test script) works fine (same node version, etc).

Could be related to the amount of source files that are being parsed? Or a large component that causes a bit too much recursion? That is the only difference I can see right now.

robisim74 commented 9 months ago

It should not depend on the number or size of files: the parser performs a sequential scan of each function p and t: https://github.com/robisim74/qwik-speak/blob/main/packages/qwik-speak/tools/core/parser.ts#L388

It seems that the tokenizer can't find the end of a function t or p, and goes into stack error.

Without recreating the problem it is difficult for me to understand why it happens, I ask you:

Also check if you have source files that shouldn't be included - you have the option excludedPaths

robisim74 commented 9 months ago

I was able to recreate the error, for example when the closing quotes are missing: <h3>{t('params)}</h3>

In version 0.20.1 I added a log of the t or p function that should generate the error

genox commented 9 months ago

Yes that is correct. In my case it was a string that looked like this: t(''Translate me').

Usually something like this should be picked up by a build or eslint. I am moving away from the previous "self made" auto key. I assume that this is an issue isolated to my use case specifically and is unlikely to end up happening regularly.

genox commented 9 months ago

👍