pionxzh / wakaru

🔪📦 Javascript decompiler for modern frontend
https://wakaru.vercel.app/
MIT License
322 stars 19 forks source link

Error [ERR_WORKER_OUT_OF_MEMORY]: Worker terminated due to reaching memory limit: JS heap out of memory #137

Open Yusufkulcu opened 1 month ago

Yusufkulcu commented 1 month ago

Describe the bug

When I use the "npx @wakaru/cli unminify" command in my js file, it gives the following error. The computer I use is extremely powerful. What should I do? I've added the relevant file below.

"Since the javascript file was not loaded, I set the extension to txt"

image

main.txt

Input code

No response

Reproduction

No response

Steps to reproduce

No response

Expected behavior

no memory error

Actual behavior

No response

0xdevalias commented 1 month ago

@Yusufkulcu Dumb question.. but did you try it again following the instructions in the warning message shown in your screenshot about how to potentially resolve out of memory issues by using the --max-old-space-size?

If you googled "node js heap out of memory" or similar you would also turn up results like this, which also talk about using --max-old-space-size:

pionxzh commented 1 month ago

The solution is to follow the instructions in the message. I think the instructions are not step-by-step, so let me give one here.

MacOS / Linux

NODE_OPTIONS="--max-old-space-size=8192" npx @wakaru/cli unminify

Windows (CMD)

set NODE_OPTIONS=--max-old-space-size=8192 && npx @wakaru/cli unminify

8192 in the command is 8GB. You can adjust the number based on your PC's specs and the size of the file.

BTW, what is the size of your input file?

Yusufkulcu commented 1 month ago

The solution is to follow the instructions in the message. I think the instructions are not step-by-step, so let me give one here.

MacOS / Linux

NODE_OPTIONS="--max-old-space-size=8192" npx @wakaru/cli unminify

Windows (CMD)

set NODE_OPTIONS=--max-old-space-size=8192 && npx @wakaru/cli unminify

8192 in the command is 8GB. You can adjust the number based on your PC's specs and the size of the file.

BTW, what is the size of your input file?

The file size is around 6-7mb. I'm trying the suggestion you said. How do we need to give the 8gb value you specified?

0xdevalias commented 1 month ago

How do we need to give the 8gb value you specified?

@Yusufkulcu I'm assuming you mean 'why do we need to specify 8gb if the file is only 6-7mb'? If so, it's because the process of unminimising the code needs to parse the plain text of the original file into a number of objects and data structures that are held and manipulated in memory, which causes it to expand to a much larger size during the process; and as the StackOverflow link I sent suggested, node has a default limit of only 1.7GB or similar.


I think the instructions are not step-by-step, so let me give one here.

@pionxzh Might be worth adding a section to the README with those instructions, and/or expanding them in the message shown in app (or maybe both/could link the in-app message to that part of the README for further details)

pionxzh commented 1 month ago

I will try to expand the instructions or link them to README to check the detailed guide.

pionxzh commented 1 month ago

The file size is around 6-7mb. I'm trying the suggestion you said. How do we need to give the 8gb value you specified?

@Yusufkulcu I give the 8GB based on your mentioned "powerful PC." Based on my experience, 6-7 MB should only need ~4GB.