I think (haven't tested) this should fix it:
Replace lines 144-147 in control.lua:
link.connect_neighbour({
wire = defines.wire_type.red,
target_entity = relay,
})
with this:
if link then
link.connect_neighbour({
wire = defines.wire_type.red,
target_entity = relay,
})
end