• Hi Gordon,

    I found the issue in the https://www.puck-js.com/puck.js code I believe. I've made some comments below.

        connection.write = function(data, callback) {
    
    // **** This is pushing callback as null ****
          if (data) txDataQueue.push({data:data,callback:cal­lback});
    // ***********************
    
          if (connection.isOpen && !connection.txInProgress) writeChunk();
    
          function writeChunk() {
            var chunk;
            if (!txDataQueue.length) return;
            var txItem = txDataQueue[0];
            if (txItem.data.length <= CHUNKSIZE) {
              chunk = txItem.data;
              txItem.data = undefined;
            } else {
              chunk = txItem.data.substr(0,CHUNKSIZE);
              txItem.data = txItem.data.substr(CHUNKSIZE);
            }
            connection.txInProgress = true;
            log("BT> Sending "+ JSON.stringify(chunk));
            txCharacteristic.writeValue(str2ab(chunk­)).then(function() {
              log("BT> Sent");
              if (!txItem.data) {
                txDataQueue.shift();
    
    // **** This is calling the null callback function and throwing an Error. ****
                txItem.callback();
    // ***************************
    
              }
              connection.txInProgress = false;
              writeChunk();
            }).catch(function(error) {
             log('BT> SEND ERROR: ' + error);
             txDataQueue = [];
    
    // **** The error is being caught and the connection is being closed. ****
             connection.close();
    // ********************
    
            });
          }
        };
    

    Like you said it's an easy fix to only call the callback if one is passed.

About

Avatar for alexjfno1 @alexjfno1 started