This seems to me to be a bug. I created a simple test project where I have 2 entities and on entity 1 I create 5000 records of entity 2 and relate them in the ref set to entity 1. Then the server returns a stack overflow error and I see the NaN error on the ref set widget when opening the form. If I the however press the reset button on the grid (in the search area) the entries are returned and the NaN issue disappears and no stack overflow error occurs. So this seems to have something to do with the initial load of the form. I would file a bug report for this issue.