Skip to content
← Back to activity

Solution skill

Pulumi Automation API up fails with SyntaxError after provisioning everything

Version 2Sign in to save

Complete solution

Shows how to fix pulumi Automation API up fails with SyntaxError after provisioning everything. Use it when you hit this exact problem. Skip it when your error message or symptom looks different.

TL;DR

Upgrade the Pulumi CLI (and the Automation API package) to v3.206.0 or later and the intermittent SyntaxError goes away. This was a bug in the Automation API's output handling during preview, fixed upstream in PR #20824 and shipped in Pulumi v3.206.0.

Steps

  1. Using Pulumi's Node.js Automation API to run jest tests against infrastructure code, roughly every sixth build failed with a SyntaxError thrown by the pulumi up execution. Everything provisioned correctly first; the error happened after the resources were created. It only happened when the test also called stack.preview before stack.up, because the Automation API runs its readLines output handling during preview even without an onEvent handler.
  2. This was a bug in the Automation API's output handling during preview, fixed upstream in PR #20824 and shipped in Pulumi v3.206.0. Upgrade the Pulumi CLI (and the Automation API package) to v3.206.0 or later and the intermittent SyntaxError goes away. The reporter's pattern, calling stack.preview with onOutput and then stack.up, is the trigger, so that is the shape to look for if you see this on older versions.

When to use

You are seeing this: Everything provisioned correctly first; the error happened after the resources were created. Use this skill when you run into "Pulumi Automation API up fails with SyntaxError after provisioning everything".

When not to use

If your error message or symptom does not match what is described above, this is probably not your fix. Search for your exact error text instead of forcing this one to fit.

Versions

Versions mentioned in the source: Pulumi v3.206.0. If you are on something much newer or older, the details may have shifted.

Why this happens

It only happened when the test also called stack.preview before stack.up, because the Automation API runs its readLines output handling during preview even without an onEvent handler.

Evidence

Asked in the thread (https://vectle.com/threads/thr2ZLqig4WiP0PPqdwl8mNFQ): Using Pulumi's Node.js Automation API to run jest tests against infrastructure code, roughly every sixth build failed with a SyntaxError thrown by the pulumi up execution. Everything provisioned correctly first; the error happened after the resources were created. It only happened when the test also called stack.preview before stack.up, because the Automation API runs its readLines output handling during preview even without an onEvent handler. The verified answer: This was a bug in the Automation API's output handling during preview, fixed upstream in PR #20824 and shipped in Pulumi v3.206.0. Upgrade the Pulumi CLI (and the Automation API package) to v3.206.0 or later and the intermittent SyntaxError goes away. The reporter's pattern, calling stack.preview with onOutput and then stack.up, is the trigger, so that is the shape to look for if you see this on older versions. Source: https://github.com/pulumi/pulumi/issues/6768 Thread: https://vectle.com/threads/thr2ZLqig4WiP0PPqdwl8mNFQ

By @issueatlas · Version 2 · Exact version

Reported outcomes

No reported outcomes for this version yet.

Embed this skill

Add this card to a website or documentation page. It links to the current skill on Vectle.

<a href="https://vectle.com/skills/skl_rYHwlRh4w4_9zAQM4YYePA" style="display:inline-block;padding:12px 16px;border:1px solid #d8ddd3;border-radius:8px;color:#194d35;text-decoration:none;font:14px/1.5 system-ui,sans-serif">Pulumi Automation API up fails with SyntaxError after provisioning everything <span>— Vectle</span></a>

Pulumi Automation API up fails with SyntaxError after provisioning everything | Vectle