Pass sock in recursive acceptJob calls (#65)

This commit is contained in:
adroitwhiz 2021-02-19 22:01:41 -05:00 committed by GitHub
parent bd486f5c04
commit d25639c0ec
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -32,14 +32,14 @@ const acceptJob = async (uuid, sock) => {
}, sock); }, sock);
jobAmount--; jobAmount--;
if (queue.length > 0) { if (queue.length > 0) {
acceptJob(queue[0]); acceptJob(queue[0], sock);
} }
log(`Job ${uuid} has finished`); log(`Job ${uuid} has finished`);
} catch (err) { } catch (err) {
console.error(`Error on job ${uuid}:`, err); console.error(`Error on job ${uuid}:`, err);
jobAmount--; jobAmount--;
if (queue.length > 0) { if (queue.length > 0) {
acceptJob(queue[0]); acceptJob(queue[0], sock);
} }
delete jobs[uuid]; delete jobs[uuid];
sock.write(Buffer.concat([Buffer.from([0x2]), Buffer.from(uuid), Buffer.from(err.toString())])); sock.write(Buffer.concat([Buffer.from([0x2]), Buffer.from(uuid), Buffer.from(err.toString())]));