Skip to content

Commit eb1a20c

Browse files
committed
don't resolve immediately
1 parent 8c1ab7a commit eb1a20c

File tree

1 file changed

+5
-5
lines changed

1 file changed

+5
-5
lines changed

uart.js

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -486,11 +486,11 @@ To do:
486486
}
487487
function onACK(ok) {
488488
tidy();
489-
resolve();
489+
setTimeout(resolve,0);
490490
}
491491
function onNAK(ok) {
492492
tidy();
493-
reject();
493+
setTimeout(reject,0);
494494
}
495495
if (!options.noACK) {
496496
connection.parsePackets = true;
@@ -501,7 +501,7 @@ To do:
501501
connection.write(String.fromCharCode(/*DLE*/16,/*SOH*/1,(flags>>8)&0xFF,flags&0xFF)+data, function() {
502502
// write complete
503503
if (options.noACK) {
504-
resolve(); // if not listening for acks, just resolve immediately
504+
setTimeout(resolve,0); // if not listening for acks, just resolve immediately
505505
}
506506
}, err => {
507507
tidy();
@@ -582,7 +582,7 @@ To do:
582582
if (type!=0x8000) return; // ignore things that are not DATA packet
583583
if (data.length==0) { // 0 length packet = EOF
584584
cleanup();
585-
resolve(fileContents);
585+
setTimeout(resolve,0,fileContents);
586586
} else {
587587
fileContents += data;
588588
scheduleTimeout();
@@ -625,7 +625,7 @@ To do:
625625
function onPacket(type,data) {
626626
if (type!=0) return; // ignore things that are not a response
627627
cleanup();
628-
resolve(parseRJSON(data));
628+
setTimeout(resolve,0,parseRJSON(data));
629629
}
630630
connection.parsePackets = true;
631631
connection.on("packet", onPacket);

0 commit comments

Comments
 (0)