Description
Describe the problem
In addition to starting the Arduino IDE application directly, it can be started by opening a specific sketch file when sketches are associated with the Arduino IDE application.
🐛 When Arduino IDE is started by opening a sketch file, an additional blank window is opened. This is annoying to the users and might cause confusion.
To reproduce
- If Arduino IDE is running, select Arduino IDE > Quit Arduino IDE from the Arduino IDE menus.
All Arduino IDE windows will close. - Control-click on any
.ino
file from a sketch.
A context menu will open. - Select "Open With" from the menu.
A submenu will open that allows you to select which application to use to open the file. - Select the Arduino IDE application from the menu.
Arduino IDE starts, with the selected sketch open as expected.
🐛 However, an additional blank Arduino window also opens.
Expected behavior
Blank Arduino windows are not created.
Arduino IDE version
Operating system
macOS
Operating system version
Sequoia
Additional context
I bisected the regression to 859d29d / #2654 (does not occur when using the build at the previous commit d298b3f).
Since this fault is similar to the one reported in #2678, I hoped this would also be fixed by #2686. However, the fault still occurs when using the tester build from that PR (e62764b).
The fault does not occur when I start Arduino IDE by passing the path of the sketch via a command line argument.
I see this in the logs when the fault occurs:
2025-04-04 12:27:30 (node:24650) UnhandledPromiseRejectionWarning: Error: Received 'open-file' event. Interrupting the default launch workflow.
at App.<anonymous> (/Applications/arduino-tools/2.x/268-e36f393.app/Contents/Resources/app/lib/backend/electron-main.js:2:1218999)
The original reporter sees a dialog when the fault occurs:
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)
Although I do encounter the blank window fault, I don't get that dialog.
Originally reported by @embedded-kiddie at https://forum.arduino.cc/t/a-javascript-error-occurred-in-the-main-process-when-i-open-some-ino-file/1370279
Issue checklist
- I searched for previous reports in the issue trackerI verified the problem still occurs when using the latest nightly buildMy report contains all necessary details
Activity
initalWindow
to be set before opening sketch throughopen-file
event #2693