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);