Modifying range names programmatically breaks any formulas in which they are used.
=sum(rangeName) becomes. =sum(#ref)
The lack of ability to create open-ended range names results in the need to add rows to existing range names for data overflows. To do so programmatically the existing range must be removed and then added back with the new definition. This process results in the breakage.
The only work around that I have found is to use the indirect function to include the range name instead of using the range name directly.
This issue has been addressed in the issue tracker at:https://code.google.com/p/google-apps-script-issues/issues/detail?id=5048