@@ -410,6 +410,7 @@ var LeaderElectionWebLock = exports.LeaderElectionWebLock = function LeaderElect
410410 // lock name
411411 this.lN = 'pubkey-bc||' + broadcastChannel.method.type + '||' + broadcastChannel.name;
412412};
413+ var LEADER_DIE_ABORT_SIGNAL_MESSAGE = 'LeaderElectionWebLock.die() called';
413414LeaderElectionWebLock.prototype = {
414415 hasLeader: function hasLeader() {
415416 var _this2 = this;
@@ -442,10 +443,19 @@ LeaderElectionWebLock.prototype = {
442443 res();
443444 return returnPromise;
444445 })["catch"](function (err) {
445- if (_this3._wKMC.rej) {
446- _this3._wKMC.rej(err);
446+ if (err.message && err.message === LEADER_DIE_ABORT_SIGNAL_MESSAGE) {
447+ /**
448+ * In this case we do nothing!
449+ * The leader died and awaitLeadership()
450+ * will never resolve. Also since this is not an error,
451+ * it will not throw.
452+ */
453+ } else {
454+ if (_this3._wKMC.rej) {
455+ _this3._wKMC.rej(err);
456+ }
457+ reject(err);
447458 }
448- reject(err);
449459 });
450460 });
451461 }
@@ -471,8 +481,13 @@ LeaderElectionWebLock.prototype = {
471481 if (this._wKMC.res) {
472482 this._wKMC.res();
473483 }
484+
485+ /**
486+ * We have to fire an abort signal
487+ * so that the navigator.locks.request stops.
488+ */
474489 if (this._wKMC.c) {
475- this._wKMC.c.abort('LeaderElectionWebLock.die() called' );
490+ this._wKMC.c.abort(new Error(LEADER_DIE_ABORT_SIGNAL_MESSAGE) );
476491 }
477492 return (0, _leaderElectionUtil.sendLeaderMessage)(this, 'death');
478493 }
@@ -24279,21 +24294,26 @@ if (hasToStringTag && gOPD && getProto) {
2427924294 // @ts-expect-error TS won't narrow inside a closure
2428024295 descriptor = gOPD(superProto, Symbol.toStringTag);
2428124296 }
24282- // @ts-expect-error TODO: fix
24283- cache['$' + typedArray] = callBind(descriptor.get);
24297+ if (descriptor && descriptor.get) {
24298+ var bound = callBind(descriptor.get);
24299+ cache[
24300+ /** @type {`$${import('.').TypedArrayName}`} */ ('$' + typedArray)
24301+ ] = bound;
24302+ }
2428424303 }
2428524304 });
2428624305} else {
2428724306 forEach(typedArrays, function (typedArray) {
2428824307 var arr = new g[typedArray]();
2428924308 var fn = arr.slice || arr.set;
2429024309 if (fn) {
24291- cache[
24292- /** @type {`$${import('.').TypedArrayName}`} */ ('$' + typedArray)
24293- ] = /** @type {import('./types').BoundSlice | import('./types').BoundSet} */ (
24310+ var bound = /** @type {import('./types').BoundSlice | import('./types').BoundSet} */ (
2429424311 // @ts-expect-error TODO FIXME
2429524312 callBind(fn)
2429624313 );
24314+ cache[
24315+ /** @type {`$${import('.').TypedArrayName}`} */ ('$' + typedArray)
24316+ ] = bound;
2429724317 }
2429824318 });
2429924319}
0 commit comments