firebase transaction repeating when committed

Hello,

I am trying to write a firebase transaction in my angular6/typescript application. Here’s what it looks like:

  console.log(‘point 1’);

        const transaction = db.runTransaction(t => {

          console.log(‘point 2’);

          const docRef = db.collection(‘Pending’).doc(req.query.inviteId);

          console.log(‘point 3’);

          const p = t.set(docRef, acceptance).commit();

          console.log('p = ', p);

          return p;

        }).then(result => {

          console.log('result = ', result);

        }).catch(err => {

          console.log('err = ', err);

        });

Here is what the output looks like:

info: point 1

info: point 2

info: point 3

info: p =  Promise { <pending> }

info: point 2

info: point 3

info: p =  Promise { <pending> }

info: point 2

info: point 3

info: p =  Promise { <pending> }

info: point 2

info: point 3

info: p =  Promise { <pending> }

info: point 2

info: point 3

info: p =  Promise { <pending> }

info: err =  { Error: 10 ABORTED: The referenced transaction has expired or is no longer valid.

    at Object.exports.createStatusError (/Users/gibranshah/repos/eva-firebasefunctions/functions/node_modules/grpc/src/common.js:87:15)

    at Object.onReceiveStatus (/Users/gibranshah/repos/eva-firebasefunctions/functions/node_modules/grpc/src/client_interceptors.js:1188:28)

    at InterceptingListener._callNext (/Users/gibranshah/repos/eva-firebasefunctions/functions/node_modules/grpc/src/client_interceptors.js:564:42)

    at InterceptingListener.onReceiveStatus (/Users/gibranshah/repos/eva-firebasefunctions/functions/node_modules/grpc/src/client_interceptors.js:614:8)

    at callback (/Users/gibranshah/repos/eva-firebasefunctions/functions/node_modules/grpc/src/client_interceptors.js:841:24)

  code: 10,

  metadata: Metadata { _internal_repr: {} },

  details: ‘The referenced transaction has expired or is no longer valid.’ }

In other words, it seems to run the transaction just fine (and I’ve verified that the data I’m trying to commit to the database is actually committed to the database), but it wants to repeat the transaction over and over until it expires, at which point the catch block prints out the error:

Error: 10 ABORTED: The referenced transaction has expired or is no longer valid.

Why does my transaction want to repeat itself until it expires? Is there something extra I need to do with p (the promise returned by t.set(…).commit())? Something to indicate to the calling function (db.runTransaction(…)) that we’re done with the transaction?

Thanks.