Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

getAmi function causes warning in test mode #2838

Closed
clstokes opened this issue Jun 17, 2019 · 2 comments
Closed

getAmi function causes warning in test mode #2838

clstokes opened this issue Jun 17, 2019 · 2 comments
Assignees
Milestone

Comments

@clstokes
Copy link
Contributor

If my Pulumi application uses getAmi to find an AMI, I get a confusing warning when running tests against the application with PULUMI_TEST_MODE. If I remove the getAmi call and hardcode an AMI ID, the test execution completes without any warning. I haven't tested if other lookup function calls cause the same warning.

Code to reproduce is at https://github.com/clstokes/pulumi-aws-ts-ruby-on-rails-unit-testing/tree/clstokes/get-ami-warning (note the clstokes/get-ami-warning branch).

Output with warning:

$ npm run test

> aws-ts-ruby-on-rails@0.1.0 test /Users/clstokes/cc/clstokes/pulumi-aws-ts-ruby-on-rails-unit-testing
> PULUMI_TEST_MODE=true PULUMI_NODEJS_PROJECT=aws-ts-ruby-on-rails PULUMI_NODEJS_STACK=fake-stack PULUMI_CONFIG='{ "aws:region": "us-west-2", "aws-ts-ruby-on-rails:dbUser": "admin2", "aws-ts-ruby-on-rails:dbPassword": "pass2", "aws-ts-ruby-on-rails:dbRootPassword": "pass2" }' mocha -r ts-node/register *.spec.ts



(node:31550) UnhandledPromiseRejectionWarning: TypeError: Cannot read property 'invoke' of undefined
    at /Users/clstokes/cc/clstokes/pulumi-aws-ts-ruby-on-rails-unit-testing/node_modules/@pulumi/pulumi/runtime/invoke.js:63:114
    at new Promise (<anonymous>)
    at Object.<anonymous> (/Users/clstokes/cc/clstokes/pulumi-aws-ts-ruby-on-rails-unit-testing/node_modules/@pulumi/pulumi/runtime/invoke.js:63:63)
    at Generator.next (<anonymous>)
    at fulfilled (/Users/clstokes/cc/clstokes/pulumi-aws-ts-ruby-on-rails-unit-testing/node_modules/@pulumi/pulumi/runtime/invoke.js:17:58)
    at processTicksAndRejections (internal/process/task_queues.js:89:5)
(node:31550) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). (rejection id: 2)
(node:31550) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.
  Infrastructure
    #server
      ✓ must have a name tag


  1 passing (234ms)

The Pulumi runtime detected that 120 promises were still active
at the time that the process exited. There are a few ways that this can occur:
  * Not using `await` or `.then` on a Promise returned from a Pulumi API
  * Introducing a cyclic dependency between two Pulumi Resources
  * A bug in the Pulumi Runtime

Leaving promises active is probably not what you want. If you are unsure about
why you are seeing this message, re-run your program with the `PULUMI_DEBUG_PROMISE_LEAKS`
environment variable. The Pulumi runtime will then print out additional
debug information about the leaked promises.
@ellismg
Copy link
Contributor

ellismg commented Jun 18, 2019

I would expect that all of these functions would fail because their implementations require a call into the engine in order to invoke data sources on the underlying providers, I don’t think there is a good way we can make things like getAmi work in general in test mode.

I think the best we could do here is make invokes fail with an exception in “test mode”

@joeduffy joeduffy self-assigned this Jul 15, 2019
@joeduffy joeduffy added this to the 0.25 milestone Jul 15, 2019
@lukehoban
Copy link
Member

Closing this out as part of what's being tracked in #2932.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants