Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 10 additions & 6 deletions src/js/msp/MSPHelper.js
Original file line number Diff line number Diff line change
Expand Up @@ -1779,13 +1779,17 @@ MspHelper.prototype.process_data = function (dataHandler) {

// remove object from array
dataHandler.callbacks.splice(i, 1);
if (!crcError) {
// fire callback
if (callback) {
callback({ command: code, data: data, length: data.byteLength, crcError: crcError });
// Always invoke callback and pass crcError flag. Callbacks expect to
// receive the original DataView so they can choose how to handle CRC
// errors; don't replace the data with null here to avoid breaking
// existing consumers that dereference response.data before checking
// crcError.
if (callback) {
try {
callback({ command: code, data: data, length: data ? data.byteLength : 0, crcError: crcError });
} catch (e) {
console.error(`callback for code ${code} threw:`, e);
}
} else {
console.warn(`code: ${code} - crc failed. No callback`);
}
}
}
Expand Down