[sdk/nodejs] Account for outstanding async work done in prepareResource (#7704)

This commit is contained in:
Evan Boyle 2021-08-04 10:27:38 -07:00 committed by GitHub
parent c0f0044a83
commit 8b918e544e
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 13 additions and 1 deletions

View file

@ -14,4 +14,7 @@
- [sdk/python] - Use `Sequence[T]` instead of `List[T]` for several `Resource`
parameters.
[#7698](https://github.com/pulumi/pulumi/pull/7698)
[#7698](https://github.com/pulumi/pulumi/pull/7698)
- [auto/nodejs] - Fix a case where inline programs could exit with outstanding async work.
[#7704](https://github.com/pulumi/pulumi/pull/7704)

View file

@ -420,6 +420,12 @@ export function registerResource(res: Resource, t: string, name: string, custom:
async function prepareResource(label: string, res: Resource, custom: boolean, remote: boolean,
props: Inputs, opts: ResourceOptions): Promise<ResourceResolverOperation> {
// add an entry to the rpc queue while we prepare the request.
// automation api inline programs that don't have stack exports can exit quickly. If we don't do this,
// sometimes they will exit right after `prepareResource` is called as a part of register resource, but before the
// .then() that adds to the queue via `runAsyncResourceOp`.
const done: () => void = rpcKeepAlive();
// Simply initialize the URN property and get prepared to resolve it later on.
// Note: a resource urn will always get a value, and thus the output property
// for it can always run .apply calls.
@ -563,6 +569,9 @@ async function prepareResource(label: string, res: Resource, custom: boolean, re
}
}
// free the RPC queue
done();
return {
resolveURN: resolveURN,
resolveID: resolveID,