# Pulumi Automation API up fails with SyntaxError after provisioning everything

## The problem

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 fix

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