Skip to content

Commit

Permalink
fix for moleculerjs#1169: getPrototypeOf instead of __proto__
Browse files Browse the repository at this point in the history
  • Loading branch information
gautaz committed Dec 19, 2022
1 parent 3e8fcef commit a091505
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
2 changes: 1 addition & 1 deletion package.json
Expand Up @@ -26,7 +26,7 @@
"memleak": "node benchmark/memleak-test.js",
"proto": "pbjs -t static-module -w commonjs -o src/serializers/proto/packets.proto.js src/serializers/proto/packets.proto",
"thrift": "thrift -gen js:node -o src\\serializers\\thrift src\\serializers\\thrift\\packets.thrift",
"test": "jest --coverage --forceExit",
"test": "NODE_OPTIONS=--disable-proto=delete jest --coverage --forceExit",
"test:unit": "jest --testMatch \"**/unit/**/*.spec.js\" --coverage",
"test:int": "jest --testMatch \"**/integration/**/*.spec.js\" --coverage",
"test:e2e": "cd test/e2e && ./start.sh",
Expand Down
6 changes: 3 additions & 3 deletions src/service-broker.js
Expand Up @@ -1775,14 +1775,14 @@ class ServiceBroker {
return schema;
}
// Depending how the schema was create the correct constructor name (from base class) will be locate on __proto__.
target = utils.getConstructorName(schema.__proto__);
target = utils.getConstructorName(Object.getPrototypeOf(schema));
if (serviceName === target) {
Object.setPrototypeOf(schema.__proto__, this.ServiceFactory);
Object.setPrototypeOf(Object.getPrototypeOf(schema), this.ServiceFactory);
return schema;
}
// This is just to handle some idiosyncrasies from Jest.
if (schema._isMockFunction) {
target = utils.getConstructorName(schema.prototype.__proto__);
target = utils.getConstructorName(Object.getPrototypeOf(schema.prototype));
if (serviceName === target) {
Object.setPrototypeOf(schema, this.ServiceFactory);
return schema;
Expand Down

0 comments on commit a091505

Please sign in to comment.