pulumi: Pulumi CLI hangs for a minute at "Previewing update"

@mikhailshilkov is frequently hitting issues with a pulumi up hanging for more than a minute. This does not reproduce consistently, and is not unique to one stack or program. It does appear to happen several times in a row and then go away.

This is on Windows.

The following two events from a pulumi up --logtostderr -v=9 --debug 2> out.txt where more than a minute apart. The rest of the update before and after this looks pretty “normal”.

I0624 17:44:34.617570   12660 eventsink.go:63] eventSink::Debug(<{%reset%}>All required Resource Providers are registered<{%reset%}>)
I0624 17:45:45.863536   12660 eventsink.go:60] Running program 'C:\work\pulumi\azure-play' in pwd 'C:\work\pulumi\azure-play' w/ args: 

About this issue

  • Original URL
  • State: closed
  • Created 7 years ago
  • Comments: 38 (28 by maintainers)

Most upvoted comments

@dsschneidermann thanks for thorough investigation we run into similar problem, when running pulumi in pipelines it would hang for several minutes before the update starts

10:39:05  eventsink.go:59] Running program 'C:\agent\_work\...\pulumi_program.ts' 
10:45:38 @ updating....................................................................................

it was in fact due to type checking in ts-node

nowadays it is possible to turn off type-checking using env variable https://github.com/pulumi/pulumi/pull/8981 setting PULUMI_NODEJS_TRANSPILE_ONLY=true resolved the long hang times

Closing my investigation here, the CLI pause is caused by ts-node running typechecks for the index.ts file and having to pull in all of the Pulumi azure-native types as well. Various attempts to speed this up, eg. importing only exactly what is needed, updating ts-node from version 7 (the 3 year old version that supports this caching) to version 10, etc, all resulted in way too slow first-time builds.

So until we port our deployments to Python, where we’ll have better control over the typecheck process, we’re using the workaround of editing the Pulumi CLI source to skip typechecking.

Having tested this approach with the AzureRM provider and azure-native, skipping typechecks and introducing various typing errors has the expected effects of causing errors during deployment, but doesn’t cause any breakage of the Pulumi stack. YMMV.

Below is my snippet for editing the Pulumi CLI to disable typechecks:

    # Disable Pulumi ts-node type checking which takes more than one minute
    # for each module deployment and must be redone on every minor change.
    # There is no way to configure Pulumi for this, so we have to change the source.
    TSNODE_TYPECHECK_LINE="typeCheck: true,"
    TSNODE_TYPECHECK_OFF="typeCheck: false, transpileOnly: true,"

    cp ../node_modules/@pulumi/pulumi/cmd/run/run.js ../node_modules/@pulumi/pulumi/cmd/run/run.js.bak
    perl -pe \
        'BEGIN {$text = q{'"$TSNODE_TYPECHECK_LINE"'}} s/\Q$text\E/'"$TSNODE_TYPECHECK_OFF"'/g' \
        < ../node_modules/@pulumi/pulumi/cmd/run/run.js.bak > ../node_modules/@pulumi/pulumi/cmd/run/run.js

@damianh Note that the symptoms you describe are almost certainly due to https://github.com/pulumi/pulumi/issues/3309. That is nominally fixed now - though there is some remaining work to make it harder to trip over this - https://github.com/pulumi/pulumi/issues/3528.

If anyone can repro this - on any platform - could you please capture a trace per https://www.pulumi.com/docs/troubleshooting/#performance and share it either here or in DM in the pulumi-community slack at https://slack.pulumi.com/.