Repository navigation
fix(scanner): bound source staging enumeration and run it under the scan timeout - #1628
Merged
Merged
Conversation
…the scan timeout Read directories in bounded batches charging the entry budget as entries arrive, create the scan deadline before staging, and copy files in context-checked chunks.
Deploying mcpproxy-docs with
|
| Latest commit: |
a034dba
|
| Status: | ✅ Deploy successful! |
| Preview URL: | https://f72bf1bd.mcpproxy-docs.pages.dev |
| Branch Preview URL: | https://fix-1602-scanner-staging-bou.mcpproxy-docs.pages.dev |
Contributor
📦 Build ArtifactsWorkflow Run: View Run Available Artifacts
How to DownloadOption 1: GitHub Web UI (easiest)
Option 2: GitHub CLI gh run download 38895224208 --repo smart-mcp-proxy/mcpproxy-go
|
|
Codecov Report❌ Patch coverage is
📢 Thoughts on this report? Let us know! |
Dumbris
added a commit
that referenced
this pull request
Oct 17, 2026
…taging deadline test (#1648) Fixes the two E2E failures on main after #1628 (#1602) that block v0.71.0. ## Root causes 1. **macOS: `TestServiceStartScanDeepOnRunsSourceResolutionAndPass2`** (run 39002404847). Not caused by #1628 (Pass 2 staging/in-process path unchanged; #1628's own main run was green). Real production race: `OnScanCompleted` spawns `startPass2` inside `executeScan`, before the deferred `clearActiveJob` frees the server's engine slot. When Pass 2 reaches `StartScan` first it is rejected with "scan already in progress", logged at Warn and dropped: no Pass 2 job is ever saved (test times out after 10s) and the resolved source dir leaked. Slow runners widen the window. 2. **Windows: `TestStagedSource_ScanDeadlineCoversStaging`**. A 1ns `context.WithTimeout` is not observably expired on the coarse Windows clock, so staging of a tiny dir finished before the ctx check. ## Fix - `ErrScanInProgress` sentinel; `startPass2` retries (bounded 10s) while the blocking job is a Pass-1 job, releases the resolved source and saves a failed Pass 2 job if it still cannot start. - Staging test now uses a 20ms timeout, plus a non-skipped source file and a stall in the `stagingAfterReadBatch` seam past the deadline, so the following ctx check deterministically fails. Still proves staging runs under the scan deadline. - New regression test `TestStartPass2WaitsForPass1SlotRelease` (fails before: Pass 2 saved as failed with "scan already in progress"). ## Verification `go test -race ./internal/security/...` green, `-count=30` on the touched tests, `GOOS=windows go vet`, both golangci-lint runs (bare and `--build-tags server`) 0 issues. The macOS flake did not reproduce locally under CPU load; diagnosis is from code plus the deterministic regression test.
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.
Summary
Tests
TestStagedSource_EntryCapEnforcedMidEnumeration: entries read stay at or under cap + one batch.TestStagedSource_CopyCancelledByDeadline: a cancelled context stops the copy.TestStagedSource_ScanDeadlineCoversStaging: an expired scan timeout stops staging withDeadlineExceeded.go test -raceoninternal/security/scanner, with and without-tags server; both golangci-lint runs clean.Closes #1602