robisim74/qwik-speak

Qwik-speak-extract: Maximum call stack exceeded

Closed this issue · 4 comments

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.

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:

  • Do you get the same error with version v0.19?
  • Have you added any particularly complex t or p functions, for example on multiple lines, with many options and parentheses?

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

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

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.

👍