Skip to content

Commit

Permalink
Make xhr transports resilient to onmessage errors
Browse files Browse the repository at this point in the history
  • Loading branch information
jcheng5 authored and whimsicallyson committed May 8, 2024
1 parent 5027318 commit c5a09c9
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion lib/transport/receiver/xhr.js
Original file line number Diff line number Diff line change
Expand Up @@ -37,12 +37,13 @@ XhrReceiver.prototype._chunkHandler = function(status, text) {
return;
}

for (var idx = -1; ; this.bufferPosition += idx + 1) {
for (var idx = -1; ; ) {
var buf = text.slice(this.bufferPosition);
idx = buf.indexOf('\n');
if (idx === -1) {
break;
}
this.bufferPosition += idx + 1;
var msg = buf.slice(0, idx);
if (msg) {
debug('message', msg);
Expand Down

0 comments on commit c5a09c9

Please sign in to comment.