pulumi/sdk/nodejs/tests
Julien 95e3d8fe26
Avoid calling invokes with dependencies on unknown resources (#18152)
Nodejs implementation of #18133

DependsOn for resources is an ordering constraint for register resource
calls. If a resource R1 depends on a resource R2, the register resource
call for R2 will happen after R1. This is ensured by awaiting the URN
for each resource dependency before calling register resource.

For invokes, this causes a problem when running under preview. During
preview, register resource immediately returns with the URN, however
this does not tell us if the resource "exists".

Instead of waiting for the dependency's URN, we wait for the ID. This
tells us that whether a physical resource exists (if the state is in
sync), and we can avoid calling the invoke when it is unknown.

The following example fails without this change:
```typescript
import * as pulumi from "@pulumi/pulumi";
import * as gcp from "@pulumi/gcp";

const config = new pulumi.Config()
const billingAccountId = config.require("billing-account")

const billingAccount = gcp.organizations.getBillingAccountOutput({
    billingAccount: billingAccountId
})

const project = new gcp.organizations.Project("project", {
    billingAccount: billingAccount.id,
    name: "project-nodejs",
    autoCreateNetwork: false,
    deletionPolicy: "DELETE",
})

export const zones = gcp.compute.getZonesOutput({
    project: project.projectId,
    region: "us-central1"
}, {
    dependsOn: [project],
})
```
2025-01-07 09:55:27 +00:00
..
automation Update golang.org/x/net throughout (#18115) 2024-12-25 17:49:25 +00:00
cmd Gracefully handle errors that don't implement toString (#18080) 2024-12-20 14:29:09 +00:00
runtime Avoid calling invokes with dependencies on unknown resources (#18152) 2025-01-07 09:55:27 +00:00
sxs_ts_test Replace Rome with Biome in the NodeJS SDK (#16456) 2024-06-24 11:14:56 +00:00
config.spec.ts Apply autoformat 2023-04-28 18:27:10 -04:00
constants.ts ci: improve x-plat testing on Windows 2022-03-06 14:45:26 -08:00
init.spec.ts Apply autoformat 2023-04-28 18:27:10 -04:00
iterable.spec.ts Apply autoformat 2023-04-28 18:27:10 -04:00
options.spec.ts Apply autoformat 2023-04-28 18:27:10 -04:00
output.spec.ts [sdk/nodejs] Throw from output() on circular structures (#17852) 2024-11-27 18:40:29 +00:00
provider.spec.ts Add google-protobuf types (#14422) 2023-10-27 09:55:44 +00:00
resource.spec.ts [sdk/nodejs] Fix provider for resource methods (#13796) 2023-08-30 14:49:53 +00:00
stackReference.spec.ts Fix TypeScript checking of Output maps of "any" values (#16959) 2024-08-15 19:09:21 +00:00
unwrap.spec.ts Apply autoformat 2023-04-28 18:27:10 -04:00
util.ts Apply autoformat 2023-04-28 18:27:10 -04:00