I am trying to understand this change: <https://g...
# typescript
I am trying to understand this change: https://github.com/pulumi/pulumi-aws/commit/c7326150f724a852bdb96b5fe13deb2a0c8a1104#diff-1d75aaef6e18290ff391879cc61091d6R10 which changed the return type of
Promise<GetSecretResult> & GetSecretResult
. Turning this into an intersection type broke some of our code, and I'm not sure why this should be an intersection at all. Could someone enlighten me? Thanks!
Hi dustin!
I made this change. The reason for it is that we're now exposing all data sources as both async/sync.
'async' for back compat (i.e. for people that explicitly used 'then' on them)
and 'sync' because it's much much easier to just call things without having to use 'await' or be in an 'async context.
and I'm not sure why this should be an intersection at all
it's an intersection because it now is "both" and you can treat it either way you want. you can still await/.then it. or you can just directly access the properties you want off of it.
cc @dazzling-memory-8548
Can you let me know what issue you ran into in terms of typings?
for example a
Promise<T> & T
should still be passible to something that expects a
and it can now be passed to something that expects a T
we are using sinonjs to stub the function, and sinon typechecks the stub that we provide against the original
our stubbed value is something like
Promise.resolve({id: "", stringValue, "", ...})
for all the values in the secret result interface
what you can do is now:
pulumi.liftProperties(Promise.resolve({id: "", stringValue, "", ...}))
nice. i'll give that a try
is there a version of that where i don't have to wrap it in a promise?
i was only doing that to match the interface
you could technically just return the raw object (Casted to any)
however, this will only work if all your consumers are updated to only access the synchronous side of these functions
i'm not a fan of casting to any if i can avoid
i.e. they don't call .then(...)
(or, just cast to
<Promise<Whatever> & Whatever>
basically, lie.
haha, i like the liftProperties idea better
i'll have to double check but i don't think we are chaining promises in our program. we do rely on outputs a lot though
i had to access via
i am getting a new error with this that i'm having trouble debugging
what's up?
err... that is something totally new. Not sure what this is about. @microscopic-florist-22719 do you know why the monitor would be null/undefined for them?
pinging this πŸ“
Are you running as under the Pulumi CLI, or are you running in test mode?
If it’s the latter, then you are probably hitting the issue you linked.
running in test mode
do you know of a workaround?
Hmm. You could monkey-patch the implementation of
to skip the actual call...
You mentioned a stubbing library
That would also work, I think?
yeah we're using sinon
I’m not familiar with Simon
(sorry, phone-bound)
Will it let you stub out arbitrary functions?
Note that in PULUMI_TEST_MODE you quite generally cannot call
methods succesfully. So you either need to monkey patch these, or use a technique more like https://www.pulumi.com/blog/unit-testing-infrastructure-in-nodejs-and-mocha/ to run tests during a real
i'll have to dig into the pulumi internals a bit to understand what/how to stub
we are using that blog post as a guide
our tests were running before the upgrade to pulumi 0.17.23 and pulumi/aws 0.18.23
if i bump @pulumi/aws to 0.18.23 i get that error
otherwise i don't
I wonder if a method name or signature changed...
Do you have sinon configured to stub out
Also, what version of
is in your package-lock.json or yarn.lock?
we do not stub out getSecretVersion all the time
do you want the locked version when the error occurs? i can get it back to a reproducible state and get that info
ok, i did
Copy code
npm i --save @pulumi/aws@0.18.23
ran tests and got the error
Copy code
> npm list @pulumi/aws
aws-typescript@ /Users/dustinfarris/Work/DLP/pulumi-ucboitlake
β”œβ”€β”€ @pulumi/aws@0.18.23
β”œβ”€β”¬ @pulumi/awsx@0.18.7
β”‚ └── @pulumi/aws@0.18.23  deduped
└─┬ pulumi-lib-aws@0.1.0 (<git+ssh://git@stash.int.colorado.edu:7999/dlp/pulumi-lib-aws.git#c95252757ebb563bf18f78f016aabb22869cdac4>)
  └── @pulumi/aws@0.18.20
Can you stub out
all the time when running tests?
I'm also wondering if the two versions of
are going to cause problems here
(perhaps only one version of
is stubbed)
will try stubbing it every time and see where that gets me
I think I'm starting to understand β€” we've been getting this error all along, but until now, it was buried in a promise that never resolved; so, the error was getting swallowed by
. As a warning, this output was a nuisance, but did not prevent us from running our tests. cc @gentle-diamond-70147 https://github.com/pulumi/pulumi/issues/2838 With the new synchronous features being introduced into Pulumi, this error is no longer trapped by a Promise, it's just an error outright, which is why our tests don't run anymore. https://github.com/pulumi/pulumi/issues/2921 is really a dupe of 2838 minus the unhandled promise rejection warning.
Good point on 2921 being a dupe of 2838 - I have closed that one out. Note that we wrote another blog post on an alternate unit testing approach that doesn't have this fundamental limitation at https://www.pulumi.com/blog/unit-testing-infrastructure-in-nodejs-and-mocha/. This works quite differently than the
approach you are using. Would love your thoughts on whether that helps for your testing scenarios.