diff --git a/examples/generated/proto/examplecom/simple_service_pb_service.js b/examples/generated/proto/examplecom/simple_service_pb_service.js index 14a5a407..bee0f019 100644 --- a/examples/generated/proto/examplecom/simple_service_pb_service.js +++ b/examples/generated/proto/examplecom/simple_service_pb_service.js @@ -77,7 +77,10 @@ SimpleServiceClient.prototype.doUnary = function doUnary(requestMessage, metadat onEnd: function (response) { if (callback) { if (response.status !== grpc.Code.OK) { - callback(Object.assign(new Error(response.statusMessage), { code: response.status, metadata: response.trailers }), null); + var err = new Error(response.statusMessage); + err.code = response.status; + err.metadata = response.trailers; + callback(err, null); } else { callback(null, response.message); } @@ -224,7 +227,10 @@ SimpleServiceClient.prototype.delete = function pb_delete(requestMessage, metada onEnd: function (response) { if (callback) { if (response.status !== grpc.Code.OK) { - callback(Object.assign(new Error(response.statusMessage), { code: response.status, metadata: response.trailers }), null); + var err = new Error(response.statusMessage); + err.code = response.status; + err.metadata = response.trailers; + callback(err, null); } else { callback(null, response.message); } diff --git a/examples/generated/proto/orphan_pb_service.js b/examples/generated/proto/orphan_pb_service.js index 979be1ea..f2f6c77e 100644 --- a/examples/generated/proto/orphan_pb_service.js +++ b/examples/generated/proto/orphan_pb_service.js @@ -48,7 +48,10 @@ OrphanServiceClient.prototype.doUnary = function doUnary(requestMessage, metadat onEnd: function (response) { if (callback) { if (response.status !== grpc.Code.OK) { - callback(Object.assign(new Error(response.statusMessage), { code: response.status, metadata: response.trailers }), null); + var err = new Error(response.statusMessage); + err.code = response.status; + err.metadata = response.trailers; + callback(err, null); } else { callback(null, response.message); } diff --git a/src/service/grpcweb.ts b/src/service/grpcweb.ts index b08a070f..d79b1af8 100644 --- a/src/service/grpcweb.ts +++ b/src/service/grpcweb.ts @@ -334,7 +334,10 @@ function printUnaryStubMethod(printer: CodePrinter, method: RPCMethodDescriptor) .printLn(`onEnd: function (response) {`) .indent().printLn(`if (callback) {`) .indent().printLn(`if (response.status !== grpc.Code.OK) {`) - .indent().printLn(`callback(Object.assign(new Error(response.statusMessage), { code: response.status, metadata: response.trailers }), null);`) + .indent().printLn(`var err = new Error(response.statusMessage);`) + .printLn(`err.code = response.status;`) + .printLn(`err.metadata = response.trailers;`) + .printLn(`callback(err, null);`) .dedent().printLn(`} else {`) .indent().printLn(`callback(null, response.message);`) .dedent().printLn(`}`)