feat(plugin-vite): enable main process hot restart via exported API#4168
Open
bglgwyng wants to merge 4 commits intoelectron:mainfrom
Open
feat(plugin-vite): enable main process hot restart via exported API#4168bglgwyng wants to merge 4 commits intoelectron:mainfrom
bglgwyng wants to merge 4 commits intoelectron:mainfrom
Conversation
BlackHole1
reviewed
Mar 16, 2026
erickzhao
approved these changes
Mar 19, 2026
BlackHole1
approved these changes
Mar 23, 2026
Add restartApp()/onAppRestart() to @electron-forge/core-utils as an explicit API for triggering Electron app restarts. The Vite plugin calls restartApp() in its closeBundle hook when the main process bundle is rebuilt. The start API registers the actual restart logic via onAppRestart(). Also backport the duplicate restart guard (!lastSpawned.restarted) to the stdin handler. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
The stdin 'rs' handler now calls restartApp() instead of duplicating the kill→respawn logic, so all restart requests flow through the single onAppRestart callback. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Prevent unnecessary terminal cursor manipulation when the Electron app has not been spawned yet. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
6c0c50e to
76aceb1
Compare
Author
|
Do we need more approvals to merge this PR? |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Add restartApp()/onAppRestart() to @electron-forge/core-utils as an explicit API for triggering Electron app restarts. The Vite plugin calls restartApp() in its closeBundle hook when the main process bundle is rebuilt. The start API registers the actual restart logic via onAppRestart(). The existing
rsstdin handler also goes through restartApp() now, so there's a single restart path.Summarize your changes:
Background
Main process hot restart for the Vite plugin has been requested and attempted multiple times:
process.stdin.emit('data', 'rs')to trigger restarts from the plugin, which reviewers flagged as a hack that should be replaced by an API exported from@electron-forge/core.process.stdincoupling issue.EventEmitter-based approach to decouple restart signaling fromprocess.stdin, but the PR was closed before merging.pluginHotRestart('restart')into@electron-forge/plugin-vite, but the restart branch was left commented out with// TODO: blocked in #3380because no cross-package restart API existed yet.What this PR does
Implements the approach suggested in #3380 and unblocks the commented-out code in #3583:
restartApp()andonAppRestart()to@electron-forge/core-utils, backed by a module-scopedEventEmitter. Plugins callrestartApp()to signal a restart; thestartAPI registers the actual kill→respawn logic viaonAppRestart().process.stdin.emit('data', 'rs')inpluginHotRestartwithrestartApp().rsstdin handler also callsrestartApp()instead of duplicating the restart logic, so both paths converge.