Fix err not defined in spawn