missing PULUMI_NODEJS_MONITOR enviroment variable ...
# typescript
s
missing PULUMI_NODEJS_MONITOR enviroment variable in nodejs package. I'm trying to use getAllocations function of nomad nodejs package. but it returns this error
Copy code
Cannot read properties of undefined (reading 'invoke')
I traced it to this line : https://github.com/pulumi/pulumi/blob/3ec1aa7/sdk/nodejs/runtime/invoke.ts#L307
Copy code
monitor.invoke(req, (err: grpc.ServiceError, innerResponse: any)
where monitor is undefined. after searching I find out that I have to set this variable PULUMI_NODEJS_MONITOR which is the monitor variable, and I don't see any documentation for it. could anyone guide me into this ? I know its related to rpc, but I couldn't find any related/helpful docs thanks.
this is the get monitor function, it returns undefined, and that's why we can't call "invoke" https://github.com/pulumi/pulumi/blob/master/sdk/nodejs/runtime/settings.ts#L392
Copy code
export function getMonitor(): resrpc.IResourceMonitorClient | undefined {
    const { settings } = getStore();
    const addr = options().monitorAddr;
    if (getLocalStore() === undefined && addr !== "mock") {
        if (monitor === undefined) {
            if (addr) {
                // Lazily initialize the RPC connection to the monitor.
                monitor = new resrpc.ResourceMonitorClient(addr, grpc.credentials.createInsecure(), grpcChannelOptions);
                settings.options.monitorAddr = addr;
            }
        }
        return monitor;
    } else {
        if (settings.monitor === undefined) {
            if (addr) {
                // Lazily initialize the RPC connection to the monitor.
                settings.monitor = new resrpc.ResourceMonitorClient(
                    addr,
                    grpc.credentials.createInsecure(),
                    grpcChannelOptions,
                );
                settings.options.monitorAddr = addr;
            }
        }
        return settings.monitor;
    }
}