Merge pull request #3789 from strongloop/nestRemoting/prevent-endless-relation-recursion

model: fix infinite loop on nestRemoting
This commit is contained in:
Kevin Delisle 2018-02-08 13:12:32 -05:00 committed by GitHub
commit 0feda03d5b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 5 additions and 1 deletions

View File

@ -873,7 +873,10 @@ module.exports = function(registry) {
var regExp = /^__([^_]+)__([^_]+)$/;
var relation = this.relations[relationName];
if (relation && relation.modelTo && relation.modelTo.sharedClass) {
if (relation && relation._nestRemotingProcessed) {
return; // Prevent unwanted circular traversals!
} else if (relation && relation.modelTo && relation.modelTo.sharedClass) {
relation._nestRemotingProcessed = true;
var self = this;
var sharedClass = this.sharedClass;
var sharedToClass = relation.modelTo.sharedClass;

View File

@ -1480,6 +1480,7 @@ describe('relations - integration', function() {
Book.hasMany(Page, {options: {nestRemoting: true}});
Book.hasMany(Chapter);
Page.hasMany(Note);
Page.belongsTo(Book, {options: {nestRemoting: true}});
Chapter.hasMany(Note);
Image.belongsTo(Book);