diff --git a/packages/nice-grpc-web/karma.conf.ts b/packages/nice-grpc-web/karma.conf.ts index 60c12d22..f46f92af 100644 --- a/packages/nice-grpc-web/karma.conf.ts +++ b/packages/nice-grpc-web/karma.conf.ts @@ -162,8 +162,8 @@ export default (config: Config & Record) => { karmaTypescriptConfig: { tsconfig: 'tsconfig.json', compilerOptions: { - target: 'ES2015', - lib: ['ES2015', 'DOM', 'DOM.Iterable'], + target: 'ES2018', + lib: ['ES2018', 'DOM', 'DOM.Iterable'], }, bundlerOptions: { constants: { diff --git a/packages/nice-grpc-web/src/__tests__/unary.ts b/packages/nice-grpc-web/src/__tests__/unary.ts index e677cec1..de8e839f 100644 --- a/packages/nice-grpc-web/src/__tests__/unary.ts +++ b/packages/nice-grpc-web/src/__tests__/unary.ts @@ -469,7 +469,7 @@ const environment = detect(); new ClientError( '/nice_grpc.test.Test2/TestUnary', Status.UNIMPLEMENTED, - '[object Object]', // this is a bug in grpc-js + 'The server does not implement the method /nice_grpc.test.Test2/TestUnary', ), ); }); diff --git a/packages/nice-grpc-web/src/client/makeCall.ts b/packages/nice-grpc-web/src/client/makeCall.ts index a8c70758..faf58dbf 100644 --- a/packages/nice-grpc-web/src/client/makeCall.ts +++ b/packages/nice-grpc-web/src/client/makeCall.ts @@ -120,6 +120,18 @@ export async function* makeCall( try { yield* response; + + if (status != null && status !== Status.OK) { + throw new ClientError(definition.path, status, message ?? ''); + } + + if (status == null) { + throw new ClientError( + definition.path, + Status.UNKNOWN, + 'Response stream closed without gRPC status', + ); + } } catch (err) { if (requestError !== undefined) { throw requestError.err; @@ -135,17 +147,6 @@ export async function* makeCall( } finally { finished = true; signal.removeEventListener('abort', abortListener); - - if (status != null && status !== Status.OK) { - throw new ClientError(definition.path, status, message ?? ''); - } - } - - if (status == null) { - throw new ClientError( - definition.path, - Status.UNKNOWN, - 'Response stream closed without gRPC status', - ); + innerAbortController.abort(); } }