Skip to content

Commit

Permalink
grpc-js: stricter function check than instanceof
Browse files Browse the repository at this point in the history
instanceof does not work in vm context
  • Loading branch information
zereraz committed Apr 21, 2021
1 parent bf2e5cb commit 076aecc
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions packages/grpc-js/src/client.ts
Expand Up @@ -198,9 +198,9 @@ export class Client {
options: CallOptions;
callback: UnaryCallback<ResponseType>;
} {
if (arg1 instanceof Function) {
if (Object.prototype.toString.call(arg1) === '[object Function]') {
return { metadata: new Metadata(), options: {}, callback: arg1 };
} else if (arg2 instanceof Function) {
} else if (Object.prototype.toString.call(arg2) === '[object Function]') {
if (arg1 instanceof Metadata) {
return { metadata: arg1, options: {}, callback: arg2 };
} else {
Expand All @@ -211,7 +211,7 @@ export class Client {
!(
arg1 instanceof Metadata &&
arg2 instanceof Object &&
arg3 instanceof Function
Object.prototype.toString.call(arg3) === '[object Function]'
)
) {
throw new Error('Incorrect arguments passed');
Expand Down

0 comments on commit 076aecc

Please sign in to comment.