The first thing that is causing the explosion is creating the chain_link at 0,0 then immediately setting the position. If you condense it into one create action it will fix that. It seems to take a tick for the physics behavior to account for repositioning.
The second problem that comes up is the links all end up being horizontal in spite of setting the angle. This is the same quirk as with position. A fix would be to make the chain over several ticks.
* "Start of layout" create the links
* "tickcount = 0" create joints between links