Same exact issue. Was driving me nuts - I was setting up a current page number marker, copying the style of an old book that had the page numbers between two m-dashes - and I couldn't get it to fit. I thought it had something to do with the marker although I know I've been able to fit the frame on page markers in the past. Turns out it's the dashes. NO idea why, all I can do is commiserate.
BTW one workaround is to turn on auto-fit under text frame options just to get it to size, and then turn it back off if you don't want to keep using it, which i don't. Prob wouldn't help with your script though...
Prob wouldn't help with your script though...
Joseph should be able to use your auto-fit work around in his script via text frame preferences in AppleScript or textFramePreferences in JS.