Skip to content

Commit

Permalink
Prevent panic while resolving a value
Browse files Browse the repository at this point in the history
  • Loading branch information
iwahbe committed Oct 28, 2022
1 parent ab21df6 commit 211bd3e
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 2 deletions.
@@ -0,0 +1,4 @@
changes:
- type: fix
scope: sdk/go,yaml
description: Prevent race on resource output
6 changes: 4 additions & 2 deletions sdk/go/pulumi/context.go
Expand Up @@ -1178,8 +1178,6 @@ func (state *resourceState) resolve(ctx *Context, err error, inputs *resourceInp
return
}

state.rawOutputs.getState().resolve(outprops, true, false, nil)

outprops["urn"] = resource.NewStringProperty(urn)
if id != "" || !dryrun {
outprops["id"] = resource.NewStringProperty(id)
Expand All @@ -1204,6 +1202,10 @@ func (state *resourceState) resolve(ctx *Context, err error, inputs *resourceInp
}
}

// We need to wait until after we finish mutating outprops to resolve. Resolving
// unlocks multithreaded access to the resolved value, making mutation a data race.
state.rawOutputs.getState().resolve(outprops, true, false, nil)

for k, output := range state.outputs {
// If this is an unknown or missing value during a dry run, do nothing.
v, ok := outprops[resource.PropertyKey(k)]
Expand Down

0 comments on commit 211bd3e

Please sign in to comment.