I’m suddenly getting `error: invalid character '}'...
# general
p
I’m suddenly getting
error: invalid character '}' after top-level value
errors using the automation api. I console logged a bit and even standalone
pulumi -v=5 stack select settlemint/development-ceks01-9afd
gives me the first error. (the stack is new using createOrSelectStack) I found two other threads here on slack where you, @red-match-15116 , debugged it with the users. Any idea what causes this or how i solve it?
r
IIRC, I believe this was caused by a mangled workspace.json file in
~/.pulumi/workspaces
due to parallel stack select calls
p
yup, deleting the folder fixes it
if the pulumi processes run in their own thread out of nodejs sdk, how would this happen? I know it cannot run concurrently in 1 node process
r
The issue is specifically with
selectStack
because it runs
pulumi stack select
, which sets the selected stack as current. Multiple processes simultaneously setting the stack as current can lead to corrupted global state which results in this mangled workspace file.
p
how would one prevent this when doing something like pulumi over http where you have no control over the calls being made?
r
It’s a bug/design flaw. We worked through a set of changes for 3.0 that fixed a lot of the other stack operations to not require stack selection and instead use the
--stack
flag to avoid changing the
current
stack - but we overlooked the
selectStack
function itself, which is now the one operation that changes global state and therefore cannot be parallelized.
p
I see, is it on the roadmap for a patch release soon? (well as it is not bc, i guess for v4?)
r
how would one prevent this when doing something like pulumi over http where you have no control over the calls being made?
The containing application should have some mechanism to serialize calls to
select
is it on the roadmap for a patch release soon?
It is not currently on the roadmap. Depending on what you’re trying to do, it is possible to work around by either serializing the calls to
select
or by running the operation on the workspace itself with the stack specified e.g.
LocalWorkspace.stackOutputs([stackName])
p
I’m trying to (consistently) have an endpoint that creates a stack and run a pulumi program. There is concurrency which is why we run this via a queue with separate processes. So everything is nicely separated by design, but since this file is in the home dir, it is shared across all pulumi runs within the same computer/docker container. Is there a way to set a path for this via some env var? Then I can put it into a dedicated tmp folder per stack.