Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

grpc: stricter function check than instanceof #1759

Merged
merged 1 commit into from Apr 20, 2021
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
8 changes: 4 additions & 4 deletions packages/grpc-native-core/src/client_interceptors.js
Expand Up @@ -1335,15 +1335,15 @@ var listenerGenerators = {
* @return {grpc~Listener}
*/
function getLastListener(method_definition, emitter, callback) {
if (emitter instanceof Function) {
if (toString.call(emitter) === '[object Function]') {
callback = emitter;
callback = function() {};
}
if (!(callback instanceof Function)) {
if (!(toString.call(callback) === '[object Function]')) {
callback = function() {};
}
if (!((emitter instanceof EventEmitter) &&
(callback instanceof Function))) {
(toString.call(callback) === '[object Function]'))) {
throw new Error('Argument mismatch in getLastListener');
}
var method_type = common.getMethodType(method_definition);
Expand Down Expand Up @@ -1376,7 +1376,7 @@ function getInterceptingCall(method_definition, options,
* @return {Interceptor}
*/
function _getLastInterceptor(method_definition, channel, responder) {
var callback = (responder instanceof Function) ? responder : function() {};
var callback = (toString.call(responder) === '[object Function]') ? responder : function() {};
var emitter = (responder instanceof EventEmitter) ? responder :
new EventEmitter();
var method_type = common.getMethodType(method_definition);
Expand Down