Repository navigation
feat: report interim compile-wait diagnostics so a stalled compile is visible before the timeout #2322
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
hatayama
merged 2 commits into
v3-beta
from
feat/report-interim-compile-wait-diagnostics
Aug 20, 2026
Merged
feat: report interim compile-wait diagnostics so a stalled compile is visible before the timeout #2322
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
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
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,4 +1,4 @@ | ||
| { | ||
| "schemaVersion": 1, | ||
| "sharedInputsHash": "0e716971c0854f6f73596d38f09343e4c97345f2" | ||
| "sharedInputsHash": "37b3868ecf195cac6405ed46a758ffa87cdc84db" | ||
| } |
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
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
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
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
131 changes: 131 additions & 0 deletions
131
cli/project-runner/internal/projectrunner/compile_wait_interim.go
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,131 @@ | ||
| package projectrunner | ||
|
|
||
| import ( | ||
| "fmt" | ||
| "io" | ||
| "time" | ||
|
|
||
| "github.com/hatayama/unity-cli-loop/common/ui" | ||
| ) | ||
|
|
||
| const ( | ||
| compileWaitInterimIntervalDefault = 60 * time.Second | ||
| compileWaitInterimSilentThreshold = 30 * time.Second | ||
| ) | ||
|
|
||
| type compileWaitInterimReporter func(string) | ||
|
|
||
| type compileWaitInterimState struct { | ||
| waitStartedAt time.Time | ||
| lastSuccessAt time.Time | ||
| lastSuccessStatus compileStatusResponse | ||
| hasSuccess bool | ||
| lastReportAt time.Time | ||
| hasReported bool | ||
| } | ||
|
|
||
| func newCompileWaitInterimState(waitStartedAt time.Time) compileWaitInterimState { | ||
| return compileWaitInterimState{waitStartedAt: waitStartedAt} | ||
| } | ||
|
|
||
| func (state *compileWaitInterimState) noteSuccessfulPoll(completedAt time.Time, status compileStatusResponse) { | ||
| state.lastSuccessAt = completedAt | ||
| state.lastSuccessStatus = status | ||
| state.hasSuccess = true | ||
| } | ||
|
|
||
| func (state *compileWaitInterimState) lineIfDue(now time.Time, interval time.Duration) (string, bool) { | ||
| if interval <= 0 { | ||
| interval = compileWaitInterimIntervalDefault | ||
| } | ||
| silentFor := now.Sub(state.silentAnchor()) | ||
| useSilent := silentFor >= compileWaitInterimSilentThreshold | ||
| if !state.isDue(now, interval, useSilent, silentFor) { | ||
| return "", false | ||
| } | ||
| state.hasReported = true | ||
| state.lastReportAt = now | ||
| if useSilent { | ||
| return formatCompileWaitSilentLine(silentFor), true | ||
| } | ||
| return formatCompileWaitProgressLine(now.Sub(state.waitStartedAt), state.lastSuccessStatus), true | ||
| } | ||
|
|
||
| func (state *compileWaitInterimState) silentAnchor() time.Time { | ||
| if state.hasSuccess { | ||
| return state.lastSuccessAt | ||
| } | ||
| return state.waitStartedAt | ||
| } | ||
|
|
||
| func (state *compileWaitInterimState) isDue( | ||
| now time.Time, | ||
| interval time.Duration, | ||
| useSilent bool, | ||
| silentFor time.Duration, | ||
| ) bool { | ||
| if state.hasReported { | ||
| return now.Sub(state.lastReportAt) >= interval | ||
| } | ||
| if useSilent { | ||
| return silentFor >= compileWaitInterimSilentThreshold | ||
| } | ||
| if !state.hasSuccess { | ||
| return false | ||
| } | ||
| return now.Sub(state.waitStartedAt) >= interval | ||
| } | ||
|
|
||
| func formatCompileWaitProgressLine(elapsed time.Duration, status compileStatusResponse) string { | ||
| return fmt.Sprintf( | ||
| "compile: still waiting for Unity (elapsed %ds; last status: is_compiling=%t, is_domain_reload_in_progress=%t).", | ||
| int(elapsed/time.Second), | ||
| status.IsCompiling, | ||
| status.IsDomainReloadInProgress, | ||
| ) | ||
| } | ||
|
|
||
| func formatCompileWaitSilentLine(silentFor time.Duration) string { | ||
| return fmt.Sprintf( | ||
| "compile: Unity has not answered status polls for %ds. The Editor may be blocked by a modal dialog or stuck; if this persists, restart Unity with 'uloop launch -r'.", | ||
| int(silentFor/time.Second), | ||
| ) | ||
| } | ||
|
|
||
| func compileWaitNow(deps compileWaitDeps) time.Time { | ||
| if deps.now != nil { | ||
| return deps.now() | ||
| } | ||
| return time.Now() | ||
| } | ||
|
|
||
| func observeCompileWaitInterim( | ||
| state *compileWaitInterimState, | ||
| deps compileWaitDeps, | ||
| status compileStatusResponse, | ||
| err error, | ||
| ) { | ||
| now := compileWaitNow(deps) | ||
| if err == nil { | ||
| state.noteSuccessfulPoll(now, status) | ||
| } | ||
| if deps.reportInterim == nil { | ||
| return | ||
| } | ||
| line, due := state.lineIfDue(now, deps.interimReportInterval) | ||
| if !due { | ||
| return | ||
| } | ||
| deps.reportInterim(line) | ||
| } | ||
|
|
||
| func bindCompileWaitInterimReporter(stderr io.Writer, spinner *ui.TerminalSpinner, deps *compileWaitDeps) { | ||
| stopped := false | ||
| deps.reportInterim = func(line string) { | ||
| if !stopped { | ||
| spinner.Stop() | ||
| stopped = true | ||
| } | ||
| _, _ = fmt.Fprintln(stderr, line) | ||
| } | ||
| } |
Oops, something went wrong.
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.
Uh oh!
There was an error while loading. Please reload this page.