From af5cd57c333feae2c960cde4421b2a4369f76f46 Mon Sep 17 00:00:00 2001 From: Brian Botha Date: Mon, 28 Feb 2022 14:28:58 +1100 Subject: [PATCH] fixes for #339 --- src/agent/service/vaultsScan.ts | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/src/agent/service/vaultsScan.ts b/src/agent/service/vaultsScan.ts index de6cd1a75a..371dfd6c83 100644 --- a/src/agent/service/vaultsScan.ts +++ b/src/agent/service/vaultsScan.ts @@ -1,18 +1,18 @@ import type * as grpc from '@grpc/grpc-js'; import type { VaultManager } from '../../vaults'; import type * as utilsPB from '../../proto/js/polykey/v1/utils/utils_pb'; -import type { ConnectionInfoGetter } from 'agent/types'; +import type { ConnectionInfoGet } from 'agent/types'; +import * as agentErrors from 'agent/errors'; import * as vaultsPB from '../../proto/js/polykey/v1/vaults/vaults_pb'; import { utils as vaultsUtils } from '../../vaults'; import { utils as grpcUtils } from '../../grpc'; -import { never } from '../../utils/utils'; function vaultsScan({ vaultManager, - connectionInfoGetter, + connectionInfoGet, }: { vaultManager: VaultManager; - connectionInfoGetter: ConnectionInfoGetter; + connectionInfoGet: ConnectionInfoGet; }) { return async ( call: grpc.ServerWritableStream, @@ -20,10 +20,12 @@ function vaultsScan({ const genWritable = grpcUtils.generatorWritable(call); const listMessage = new vaultsPB.List(); // Getting the NodeId from the ReverseProxy connection info - const connectionInfo = connectionInfoGetter(call.getPeer()); + const connectionInfo = connectionInfoGet(call); // If this is getting run the connection exists // It SHOULD exist here - if (connectionInfo == null) never(); + if (connectionInfo == null) { + throw new agentErrors.ErrorConnectionInfoMissing(); + } const nodeId = connectionInfo.nodeId; try { const listResponse = vaultManager.handleScanVaults(nodeId);