fix: prevent dev mode bundle deletion race condition#6419
Open
JoshuaShunk wants to merge 1 commit intoanomalyco:devfrom
Open
fix: prevent dev mode bundle deletion race condition#6419JoshuaShunk wants to merge 1 commit intoanomalyco:devfrom
JoshuaShunk wants to merge 1 commit intoanomalyco:devfrom
Conversation
vimtor
reviewed
Feb 20, 2026
Comment on lines
+192
to
+208
| // check that the handler file still exists on disk | ||
| handlerFile := build.Handler | ||
| if i := strings.LastIndex(handlerFile, "."); i > 0 { | ||
| handlerFile = handlerFile[:i] | ||
| } | ||
| matches, _ := filepath.Glob(filepath.Join(build.Out, handlerFile+".*")) | ||
| if len(matches) == 0 { | ||
| // also check without extension for compiled binaries | ||
| if _, err := os.Stat(filepath.Join(build.Out, handlerFile)); err != nil { | ||
| log.Info("build output missing, rebuilding", "functionID", functionID, "handler", build.Handler) | ||
| delete(builds, functionID) | ||
| } else { | ||
| return build | ||
| } | ||
| } else { | ||
| return build | ||
| } |
Collaborator
There was a problem hiding this comment.
thansk for your contribution @JoshuaShunk
i'm thinking maybe we don't need this complex logic given the fix in runtime.go should prevent this altogether
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
Fixes #6416
In
sst dev,Build()callsos.RemoveAllon the artifacts directory before every rebuild. In dev mode, esbuild maintains a persistent context and overwrites output files in place viaRebuild(), so the full directory wipe is unnecessary. When multiple Lambda bridge instances connect for the same function (common with CloudFront/Router), this creates a race condition where running workers lose theirbundle.mjsmid-flight.Changes:
os.RemoveAllon the artifacts output directory during dev mode rebuildsgetBuildOutput()by checking the handler file still exists on disk before returning a cache hit — if missing, invalidate the cache and trigger a rebuildTest plan
go vet ./...passesgo test ./pkg/...passesgo build ./cmd/sstsucceeds