sevenwestmedia-labs / pulumi

Collection of Pulumi modules we have built
9 stars 5 forks source link

UnhandledPromiseRejectionWarning: TypeError: Incorrectly typed arguments to startBatch #4

Open kaaloo opened 4 years ago

kaaloo commented 4 years ago

Hi,

I came across your Medium post on pulumi-run-fargate-task today and it's exactly what I was looking for ! I unfortunately got bit by a compilation error, namely with

import pulumi from '@pulumi/pulumi'
import awsx from '@pulumi/awsx'

in fargate-run-task.ts and

import awsSdk from 'aws-sdk'

in runFargateTask.ts. These were easy enough to fix, but then when I actually call FargateRunTask I'm getting an exception:

  pulumi:pulumi:Stack (aws-architecture-dev):
    error: update failed

    (node:24873) UnhandledPromiseRejectionWarning: TypeError: Incorrectly typed arguments to startBatch
        at handleError (/home/luis/Code/outmind/outmind-app/aws-architecture/node_modules/grpc/src/server.js:72:8)
        at sendUnaryData (/home/luis/Code/outmind/outmind-app/aws-architecture/node_modules/grpc/src/server.js:598:9)
        at Object.<anonymous> (/home/luis/Code/outmind/outmind-app/aws-architecture/node_modules/@pulumi/pulumi/cmd/dynamic-provider/index.js:184:20)
        at Generator.throw (<anonymous>)
        at rejected (/home/luis/Code/outmind/outmind-app/aws-architecture/node_modules/@pulumi/pulumi/cmd/dynamic-provider/index.js:19:65)
    (node:24873) 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:24873) [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.

I tried wrapping bits of code in pulumi-run-fargate-task in try / catch blocks to no avail. Any idea what could be happening here? I really love this approach and would like to use it in my code.

Thanks, Luis

JakeGinnivan commented 4 years ago

Hey Luis, thanks for the report. Will look into it and get it sorted this morning!

kaaloo commented 4 years ago

Hey Jake, I saw two different grpc versions in my node_modules so I cleaned that up but the problem persists. Googling around I came across this issue https://github.com/grpc/grpc-node/issues/369 which seems very similar to what I'm experiencing. When the FargateRunTask constructor is called the pulumi deployment just hangs, then when exiting with Ctrl-C twice you get the above behavior.

kaaloo commented 4 years ago

So Jake, the issue arises if you don't have a aws:region key setup in your config. It's weird because I do have the region set up but maybe there is an issue with the Pulumi yaml file name. In any case I traced the error down to that. So to fix this it could be a simple README.md update stating that the region is required, but even better it would be good to throw an Error if the region is not present in the config.

JakeGinnivan commented 4 years ago

Thanks for looking into it, I had started creating an example project in here and tracking it down. Then my new mac died so needed to get it replaced.

Will try to improve over the next few days now I am up and running again

kaaloo commented 4 years ago

Hello Jake, I found and interesting discussion on the Pulumi Slack which provides a workaround to the aws:region issue:

https://pulumi-community.slack.com/archives/C84L4E3N1/p1566586569018900?thread_ts=1566586569.018900

Basically, you have to get the awsRegion value outside of the body of the dynamic resource provider. I'll test this and send you a PR for the issues I've found if it works.