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

MacOS x64 build failed while signing with Fatal JavaScript invalid size error with many extraResouces files/folders #325

Open
KillerCodeMonkey opened this issue Jul 12, 2024 · 0 comments

Comments

@KillerCodeMonkey
Copy link

KillerCodeMonkey commented Jul 12, 2024

I created an issue at electron-builder, but i debugged and invested time to nail it down and it seems it is an osx-sign issue:

Check:
electron-userland/electron-builder#8306

Long story short:

I have an angular app that i add as "extraResources" with electron builder to the electron app.
There are many files in there, because i have a custom pdfjs version with all its files, e.g. many many cmaps.

Since osx-sign is going through all folder and files inside "Content" it reaches some limits and dies.

a little reproduction repo: https://github.com/fdk-app/electron-osx-sign-invalid-size-error
its just an empty electron-vite project + the www-folder as extra resources. I added there only the assets of a library we use, which are more or less pdfjs, but i added the cmaps folder multiple times.

Signing dies directly after it starts - check the build github action at the repo.

remove some "cmaps" folders and it works.

The problem i see here is, that even i worked around in our production app for now, we will reach that point again because our angular app will grow as well.

Just a guess maybe it is that "isBinaryFile" check which is leading to that problem. it uses Buffer.alloc which allocs new space foreach file and since the walkfiles is running recursive and in parallel for each files it will easy explode.

https://github.com/electron/osx-sign/blob/main/src/util.ts#L153

BTW: this isBinaryFile library is running "stat" again.

A possible solution, but maybe breaks some other really really edge cases (some unknown file extensions/custom extensions or false/no extension) is to use some not that strict checks...

like just test file extensions:
https://github.com/sindresorhus/is-binary-path

Or do not everything in parallel/run in batches this will slow down the signing a little bit, but maybe the garbage collector has the chance to clean things up in between.

Or batch and use isBinaryFile but pass the buffer on your own, so no additional stat call is done

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

No branches or pull requests

1 participant