Fixed various issues in internal/engine/types - #450
#450Merged
SuperCoolPencil merged 12 commits intoMay 15, 2026
Merged
Conversation
…since surge does not reuse old conns to the same host since HTTP 1.1 is one way
… allowed a 0 value. Made both them consistent with each other
…s in one place and getters in one place
…tings into RuntimeConfig
…ooking at its shape which may cause silent failures
Comment on lines
+350
to
+352
| if aliasValue != 0 && (aliasValue < 1 || aliasValue > 64) { | ||
| warnings = append(warnings, fmt.Sprintf("Max connections/download reset to default (%d)", defaults.MaxConnectionsPerDownload)) | ||
| } |
Contributor
There was a problem hiding this comment.
Duplicate warning for a single misconfiguration
When the deprecated MaxConnectionsPerHost alias carries an out-of-range value (e.g., 999) while MaxConnectionsPerDownload is 0, the switch copies the bad value into MaxConnectionsPerDownload, triggering the first if block (which resets and emits warning 1), and then the second if block also fires on the original aliasValue (emitting an identical warning 2). The user sees two identical "Max connections/download reset to default" warnings for a single issue. Because MaxConnectionsPerHost is tagged json:"-" it is only ever set programmatically, so this is primarily a concern for tests and migration code, but it still obscures diagnostics.
Prompt To Fix With AI
This is a comment left during a code review.
Path: internal/config/settings.go
Line: 350-352
Comment:
**Duplicate warning for a single misconfiguration**
When the deprecated `MaxConnectionsPerHost` alias carries an out-of-range value (e.g., `999`) while `MaxConnectionsPerDownload` is `0`, the switch copies the bad value into `MaxConnectionsPerDownload`, triggering the first `if` block (which resets and emits warning 1), and then the second `if` block also fires on the original `aliasValue` (emitting an identical warning 2). The user sees two identical "Max connections/download reset to default" warnings for a single issue. Because `MaxConnectionsPerHost` is tagged `json:"-"` it is only ever set programmatically, so this is primarily a concern for tests and migration code, but it still obscures diagnostics.
How can I resolve this? If you propose a fix, please make it concise.
StressTestor
pushed a commit
to StressTestor/Surge
that referenced
this pull request
Jun 1, 2026
* refactor: Renamed maxConnectionsPerHost to maxConnectionsPerDownload since surge does not reuse old conns to the same host since HTTP 1.1 is one way * fix(config): Did not accept 0 value for some fields although settings allowed a 0 value. Made both them consistent with each other * refactor(config): Removed unnecessary what comments and kept constants in one place and getters in one place * refactor(internal): Removed duplicate function to convert runtime settings into RuntimeConfig * test: Added tests in accuracy_test to increase test coverage * fix: Fixed a bug where download resume trusted chunk bitmap without looking at its shape which may cause silent failures * refacor: Fixed a failing test and added better comments * refactor: renamed maxdownloadsperhost to maxdownloadsperDownload * fix: Fixed a failing regression test * fix: Fixed sparse runtime configs
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.
Greptile Summary
This PR consolidates the dual
RuntimeConfigstructs (one ininternal/config, one ininternal/engine/types) into a singletypes.RuntimeConfig, renamesMaxConnectionsPerHost→MaxConnectionsPerDownloadthroughout the codebase, and introducesDefaultRuntimeConfig()so callers no longer create sparse struct literals that silently disable health-check features.MaxConnectionsPerHost→MaxConnectionsPerDownloadacross 29 files; getter fallback constant changed fromPerHostMax = 64toPerDownloadMax = 32; a deprecatedMaxConnectionsPerHostalias (taggedjson:\"-\") is retained inNetworkSettingsfor backward compatibility.StallTimeout,SlowWorkerThreshold,SlowWorkerGracePeriod,SpeedEmaAlpha) now treat zero as "opt-out" rather than falling back to the package default, backed by matching guards inhealth.goandworker.go.Download()and both downloader constructors now useDefaultRuntimeConfig()to fix the stall/slow-worker regression.RestoreBitmapnow allocates a correctly-sized bitmap and copies into it, preventing a panic when a persisted bitmap is shorter than expected.Confidence Score: 5/5
Safe to merge; all production paths now use DefaultRuntimeConfig() so health checks remain active, and bitmap normalisation prevents resume-time panics.
The core fixes are correct and well-tested. Two undocumented constant changes (SlowWorkerThreshold 0.50→0.30 and StallTimeout 5s→3s) alter engine behaviour for all default-settings users, and a minor getter asymmetry means MaxTaskRetries=0 cannot disable retries while its sibling fields can be zeroed to opt out.
internal/engine/types/config.go — the constant and getter-semantics changes are the most impactful and least documented part of this PR.
Important Files Changed
Prompt To Fix All With AI
Reviews (2): Last reviewed commit: "fix: Fixed sparse runtime configs" | Re-trigger Greptile