diff --git a/lib/model.js b/lib/model.js index 2a0e9497..f27c04ee 100644 --- a/lib/model.js +++ b/lib/model.js @@ -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; diff --git a/test/relations.integration.js b/test/relations.integration.js index ffd822cf..0d9432b2 100644 --- a/test/relations.integration.js +++ b/test/relations.integration.js @@ -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);