From b6846f0709509e77523fa34b539c7840b5d5e83f Mon Sep 17 00:00:00 2001 From: Michael Lumish Date: Tue, 21 Apr 2020 10:32:58 -0700 Subject: [PATCH] Update server to handle default schemes --- packages/grpc-js/src/server.ts | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/packages/grpc-js/src/server.ts b/packages/grpc-js/src/server.ts index 95aa68a2..c8b8f2b2 100644 --- a/packages/grpc-js/src/server.ts +++ b/packages/grpc-js/src/server.ts @@ -45,7 +45,7 @@ import { } from './server-call'; import { ServerCredentials } from './server-credentials'; import { ChannelOptions } from './channel-options'; -import { createResolver, ResolverListener } from './resolver'; +import { createResolver, ResolverListener, mapUriDefaultScheme } from './resolver'; import { log } from './logging'; import { SubchannelAddress, @@ -226,10 +226,14 @@ export class Server { throw new TypeError('callback must be a function'); } - const portUri = parseUri(port); - if (portUri === null) { + const initialPortUri = parseUri(port); + if (initialPortUri === null) { throw new Error(`Could not parse port "${port}"`); } + const portUri = mapUriDefaultScheme(initialPortUri); + if (portUri === null) { + throw new Error(`Could not get a default scheme for port "${port}"`); + } const serverOptions: http2.ServerOptions = {}; if ('grpc.max_concurrent_streams' in this.options) {