fix: improve developing experience with Electron on Windows #796
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.
Description
Currently, it is very inconvenient to develop with Electron on windows:
When developers run
pnpm run dev
in terminal, an electron instance will be started.Then it alerts developer to login. After logging in in the opened browser, we are required to open
follow-dev://auth?token=xxx
in the browser to continue.That's the problem. A separate electron instance will be started instead of using the already running one.
For the second instance, it does not have the environment variable needed to launch (including ELECTRON_RENDERER_URL and those in .env), which is loaded by the first instance but not passed to the second instance.
The essential question we need to address is why the second instance was initiated (why requestSingleInstanceLock not work).
So that's why. The second instance is launched by the system and not having the NODE_ENV configured to "development".
And it will make the second instance's appData directory to be
Follow
instead ofFollow (dev)
. Different appData directory means different instances.So the solution is to check if the process is started with
follow-dev:
and set the NODE_ENV for it.And now, we can develop with Electron on Windows very happily. 😁 (Remember set
VITE_API_URL
tohttps://api.follow.is
in.env
file)Linked Issues
#672, #778
Additional context