fix(plugin-vite): Ensure rendererUrl is set before calling dev(userCo… #1055
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.
起因
详见:ArcherGu/fast-vite-electron#1074 ,在其他电脑(macos)中也复现了该问题。重复
启动-停止-启动
的过程中有可能会出现该问题。同时我也观察到在日志中DSB xx
的日志优先printUrls()
的内容输出时就会报错,也侧面证明了存在竞态条件的问题。描述
解决了 Vite Plugin Doubleshot 插件中一个潜在的竞态条件问题。在 Vite 开发服务器启动时,
rendererUrl
可能在调用dev(userConfig)
之前没有正确设置,导致rendererUrl
的值不正确,从而在开发过程中引发问题。变更内容
• 添加标志:引入了一个 rendererUrlSet 标志,用于跟踪 rendererUrl 是否已被设置。
• 修改 server.printUrls:调整了该方法以设置 rendererUrl 并更新 rendererUrlSet 标志。
• 更新 listening 事件处理器:确保在调用 dev(userConfig) 之前检查 rendererUrlSet 标志,并确保 rendererUrl 已被设置。