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

fix: recursion error (max call stack size exceeded) #6

Merged
merged 2 commits into from Sep 25, 2022

Conversation

hrueger
Copy link
Contributor

@hrueger hrueger commented Sep 24, 2022

Hi @toyobayashi,
I just updated my application from electron 17 to electron 20 and I suddenly started to get a Maximum call stack size exceeded error.
I don't have the exact stack trace anymore, but splitPath calls statSync and this calles splitPath again... This will go on forever until the maximum call stack size is exceeded.

I don't know what introduced this problem since I did not update asar-node, just other packages.
This PR, however, seems to fix it, although I don't know if that has sideeffects.

@toyobayashi
Copy link
Owner

@hrueger Thank you for your feedback.

I just updated my application from electron 17 to electron 20

You mean you are using asar-node in electron runtime environment?

The statSync here should have been the original fs.statSync, but I don't know why it becomes the overwritten one.

I don't recommend adding an outsideAsar option which changes the original function behavior

Could you provide a minimum reproduce code repo?

@hrueger
Copy link
Contributor Author

hrueger commented Sep 24, 2022

You mean you are using asar-node in electron runtime environment?

Correct.

Could you provide a minimum reproduce code repo?

I'll see what I can do, but unfortunately not today. My application is quite complex.
Maybe it's interesting to know that I'm using the module in a worker_thread?

@hrueger
Copy link
Contributor Author

hrueger commented Sep 25, 2022

Oh, thanks for the fix 👍
I'll test that right now and get back to you.

@toyobayashi
Copy link
Owner

electron/electron#33216 seems to be related to this problem.

Now I found 'electron' in process.versions is always false in worker threads. I didn't realize that asar-node always use require('fs') instead of require('original-fs') in electron's worker threads until now.

Perhaps electron/electron#33216 make require('fs') changed in worker threads, then caused this.

Before:

16

After:

20

@toyobayashi
Copy link
Owner

In my understand, the electron environment itself provides all the functionality of asar-node, why do you need to use asar-node in worker threads?

@hrueger
Copy link
Contributor Author

hrueger commented Sep 25, 2022

I need to require modules in there and I remember that this did not work without asar-node... However, I'll try it without asar-node.

@hrueger
Copy link
Contributor Author

hrueger commented Sep 25, 2022

I can happily report that your fix also works. Now I'll try without asar-node at all.

@toyobayashi
Copy link
Owner

I guess your code can work without asar-node on electron version >= 17.3.0, which have electron/electron#33216 merged.

@hrueger
Copy link
Contributor Author

hrueger commented Sep 25, 2022

That makes sense, thanks for your help 👍
Yes, I was using electron v17.1.2 before.

@toyobayashi toyobayashi merged commit b161e4b into toyobayashi:master Sep 25, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants