Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 17 additions & 1 deletion cmd/sst/mosaic/aws/function.go
Original file line number Diff line number Diff line change
Expand Up @@ -189,7 +189,23 @@ func function(ctx context.Context, input input) {
getBuildOutput := func(functionID string) *runtime.BuildOutput {
build := builds[functionID]
if build != nil {
return build
// 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
}
}
target, _ := targets[functionID]
build, err := input.project.Runtime.Build(ctx, target)
Expand Down
11 changes: 7 additions & 4 deletions pkg/runtime/runtime.go
Original file line number Diff line number Diff line change
Expand Up @@ -107,11 +107,14 @@ func (c *Collection) Build(ctx context.Context, input *BuildInput) (*BuildOutput
}

if input.Bundle == "" {
err := os.RemoveAll(out)
if err != nil {
return nil, err
// skip removing in dev mode so running workers don't lose their bundle files
if !input.Dev {
err := os.RemoveAll(out)
if err != nil {
return nil, err
}
}
err = os.MkdirAll(out, 0755)
err := os.MkdirAll(out, 0755)
if err != nil {
return nil, err
}
Expand Down