"A JavaScript error occurred in the main process" when I open some .ino file

When I open a .ino file, the empty sketch window opens, and almost the all operations in the IDE menu (except Quit Arduino IDE) would cause the following:

It says:

A JavaScript error occurred in the main process
Uncaught Exception:
TypeError: Object has been destroyed
at _.send (node:electron/js2c/browser_init:2:73448)
at t.nodeId.r.click (/Applications/Arduino IDE.app/Contents/Resources/app/lib/backend/electron-main.js:5:29489)
at MenuItem.click (node:electron/js2c/browser_init:2:33700)
at a._executeCommand (node:electron/js2c/browser_init:2:39128)

I found the same issue but it had not been resolved:

My environment

MacBook Pro (Intel Mac) / MacOS 11.7.10(Big Sur)
Arduino IDE 2.3.5

I've done the following but it doesn't fix the issue.

  • Remove the following folders base on this document
    • /Users/{username}/Library/Arduino15
    • /Users/{username}/.arduinoIDE
  • Uninstall Arduino IDE and re-install.

How can I fix this issue?
Thanks in advance.

Hi @embeddedkiddie.

I'm not sure I understood correctly what you mean by this. Please provide detailed step-by-step instructions I could follow to reproduce the problem on my computer.

Hi @ptillisch ,
Thank you for your replying.

There are many projects in my sketch folder. For example:

Arduino/SD_Test
└── SD_Test.ino

When I double click SD_Test.ino, two windows opens. One is for SD_Test.ino, and the other is blank window which I attached in post #1.

However, if I open the IDE directly from the Applications folder without specifying any .ino file, it will only open the last sketch I opened.

Does what I'm saying make sense?
Thanks.

Hi @ptillisch ,

My memory is hazy so it may be difficult to reproduce the problem, but I will try.

  1. I opened some .ino file, e.g. SD_Test.ino for example in post #3. At this time the ESP32 board package was 3.1.3.
  2. I opened another .ino file to test something. I re-install the board package 2.0.17, then compiled & uploaded.
  3. During I was switching between 2.0.17 and 3.1.3 several times to test something, the IDE hung up. I couldn't quit from the IDE menu or "x" button on the top left of the sketch window, so I forced the Arduino IDE to quit with "option + command + ESC".
  4. I reboot my Mac just to be sure.
  5. The issue started happening after a reboot.

I also removed all the cache files in /Users/{username}/Library/Caches/arduino/sketches/, but the issue is still here.

Is it possible that a terminated process is still somewhere?
Or do you have any idea?

Thank you!

3 posts were split to a new topic: IDE restarts while compiling sketch

Thanks. This information allowed me to reproduce the fault. I submitted a formal bug report to the Arduino IDE developers on your behalf:

Thanks for bringing this to our attention!

You can subscribe to that thread to get notifications of any new developments related to this subject:


:red_exclamation_mark: Please only comment on the GitHub issue thread if you have new technical information that will assist with the resolution. General discussion and support requests are always welcome here on the Arduino Forum.


I think that was a different problem, which just happened to also produce one of those "A JavaScript error occurred in the main process" dialogs.

For now, I recommend starting the Arduino IDE application directly, rather than by opening a sketch. Once Arduino IDE is running, you can then open sketches without encountering the problem.

Alternatively, if you do want to start Arduino IDE by opening a sketch, it should be possible to simply close that extra blank window. From my experiments, Arduino IDE is completely functional under these conditions, so the bug is an annoyance (and source of potential confusion for users who first encounter it) rather than a show stopper.

Hi @ptillisch ,
Thank you for your support and also creating the issue on GitHub. I subscribe it.

I reverted the IDE version from 2.3.5 to 2.3.4 and the issue disappeared.

Another problem with 2.3.5 is that if there is a sketch being compiling, it is always brought to the foreground, so I cannot edit other open sketches.
This is very annoying and gets in the way of coding.

So I'd skip 2.3.5.

The bug has been reported here:

and already fixed last week:

The blank window bug you reported here has also been fixed:

Thank you for your feedback.
I'm looking forward to 2.3.6 :grin:

1 Like