repositories / pi-ext

pi-ext

bugabingas pi extensions

owned by bugabinga

fix(pulse): ignore stale context callbacks

1749631179036d73e074d10188ded9aa475a795c

Oliver Jan Krylow <oliver@bugabinga.net> ·

unsigned

Browse filesCompare with HEAD

Changed files (1)

+20 / −4 text lines

Diff layout

extensions/pulse/index.ts

Modified

+20 / −4 text lines

662662 if (!reloaded) return;
663663 state.config = reloaded;
664664 state.isTracking = state.config.documents.length > 0;
665 setStatus(ctx);
665 // Captured ctx from the watcher closure can be
666 // invalidated by ctx.reload() between ticket check and use;
667 // session_start reinstalls the watcher with a fresh ctx.
668 try {
669 setStatus(ctx);
670 } catch {}
666671 }, CONFIG_WATCHER_DEBOUNCE_MS);
667672 });
668673 state.configWatcher.on("error", () => {
960965 state.isChecking
961966 )
962967 return;
963 if (typeof ctx.isIdle === "function" && !ctx.isIdle()) {
964 setStatus(ctx);
965 return;
968 // Captured ctx from the timer closure can be invalidated by
969 // ctx.reload() between ticket check and use; next session_start
970 // installs a fresh timer with a fresh ctx, so just bail.
971 if (typeof ctx.isIdle === "function") {
972 let idle: boolean;
973 try {
974 idle = ctx.isIdle();
975 } catch {
976 return;
977 }
978 if (!idle) {
979 setStatus(ctx);
980 return;
981 }
966982 }
968984 reconcileMaybeDirty();