Skip to content

LS: [WARN] Fetch proxy did not signal ready within timeout (1.7.3) #34

@SaiyanOfDarkness

Description

@SaiyanOfDarkness
"use strict";(()=>{var we=typeof browser<"u"?browser:chrome,A=we;var h={version:1,enabled:!0,keep:10,showStatusBar:!0,collapseLongUserMessages:!0,debug:!1,ultraLean:!1},H={BOOT_DURATION_MS:1500,DEBOUNCE_MS:75,BATCH_BUDGET_MS:16,NODES_PER_BATCH:7,SCROLL_THROTTLE_MS:100,MESSAGE_TIMEOUT_MS:500,MESSAGE_RETRY_DELAYS_MS:[50,100,200],PROXY_READY_TIMEOUT_MS:1e3,STATUS_BAR_THROTTLE_MS:500},k="LS:",D={MIN_KEEP:1,MAX_KEEP:100};var ne=!1,U={log:(...e)=>{try{console?.log?.(...e)}catch{}},warn:(...e)=>{try{console?.warn?.(...e)}catch{}},error:(...e)=>{try{console?.error?.(...e)}catch{}}};function oe(e){ne=e}function d(e,...t){ne&&U.log(`[${k}DEBUG]`,e,...t)}function T(e,...t){U.warn(`[${k}WARN]`,e,...t)}function g(e,...t){U.error(`[${k}ERROR]`,e,...t)}function M(e,...t){U.log(`[${k}INFO]`,e,...t)}var se="ls_settings",xe="ls_config";function O(e){return{version:1,enabled:e.enabled??h.enabled,keep:Math.max(D.MIN_KEEP,Math.min(D.MAX_KEEP,e.keep??h.keep)),showStatusBar:e.showStatusBar??h.showStatusBar,collapseLongUserMessages:e.collapseLongUserMessages??h.collapseLongUserMessages,debug:e.debug??h.debug,ultraLean:e.ultraLean??h.ultraLean}}function q(e){if(typeof localStorage>"u"){d("localStorage not available (service worker context)");return}try{let t={enabled:e.enabled,limit:e.keep,debug:e.debug};localStorage.setItem(xe,JSON.stringify(t)),d("Synced settings to localStorage:",t)}catch(t){g("Failed to sync to localStorage:",t)}}async function re(){try{let t=(await A.storage.local.get(se))[se];return t?(d("Loaded settings from storage:",t),O(t)):(d("No stored settings found, using defaults"),O({}))}catch(e){return g("Failed to load settings:",e),O({})}}var z="lightsession-status-bar",Ce="LightSession \xB7 waiting for messages\u2026",y=null,x=!0,B=0,w=null,m=null;function I(){let e=document.getElementById(z);return e||(e=document.createElement("div"),e.id=z,e.setAttribute("role","status"),e.setAttribute("aria-live","polite"),_e(e),document.body.appendChild(e),e)}function _e(e){Object.assign(e.style,{position:"fixed",bottom:"3.5px",right:"24px",zIndex:"10000",padding:"4px 10px",fontSize:"11px",fontFamily:'-apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif',fontWeight:"500",color:"#e5e7eb",backgroundColor:"rgba(15, 23, 42, 0.9)",border:"1px solid rgba(55, 65, 81, 0.9)",borderRadius:"9999px",boxShadow:"0 2px 8px rgba(0, 0, 0, 0.3)",backdropFilter:"blur(4px)",maxWidth:"60%",whiteSpace:"nowrap",overflow:"hidden",textOverflow:"ellipsis",pointerEvents:"none",transition:"opacity 0.2s ease"})}function G(e){return e.trimmedMessages>0?{text:`LightSession \xB7 last ${e.keepLastN} \xB7 ${e.trimmedMessages} trimmed`,state:"active"}:e.totalMessages===0?{text:"LightSession \xB7 waiting for messages\u2026",state:"waiting"}:e.totalMessages<=e.keepLastN?{text:`LightSession \xB7 all ${e.totalMessages} visible`,state:"all-visible"}:{text:`LightSession \xB7 ${e.visibleMessages} visible`,state:"active"}}function P(e,t){switch(e.style.opacity="1",e.style.color="#e5e7eb",e.style.backgroundColor="rgba(15, 23, 42, 0.9)",e.style.borderColor="rgba(55, 65, 81, 0.9)",t){case"active":e.style.color="#6ee7b7",e.style.backgroundColor="rgba(6, 78, 59, 0.9)",e.style.borderColor="rgba(16, 185, 129, 0.5)";break;case"waiting":e.style.color="#9ca3af";break;case"all-visible":break;case"unrecognized":e.style.color="#fcd34d",e.style.backgroundColor="rgba(120, 53, 15, 0.9)",e.style.borderColor="rgba(217, 119, 6, 0.5)";break}}function Ae(e,t){return e===null||t===null?e===t:e.totalMessages===t.totalMessages&&e.visibleMessages===t.visibleMessages&&e.trimmedMessages===t.trimmedMessages&&e.keepLastN===t.keepLastN}function ie(e){let t=I();if(!t)return;let{text:n,state:s}=G(e);t.textContent=n,P(t,s),B=performance.now()}function $(e){e.textContent=Ce,P(e,"waiting"),B=performance.now()}function le(e){let t=e;if(Ae(t,y)||(y=t,!x))return;let s=performance.now()-B;if(s>=H.STATUS_BAR_THROTTLE_MS)m!==null&&(clearTimeout(m),m=null),w=null,ie(t);else if(w=t,m===null){let o=H.STATUS_BAR_THROTTLE_MS-s;m=window.setTimeout(()=>{m=null,w&&x&&(ie(w),w=null)},o)}}function He(){x=!0;let e=I();if(e){if(e.style.display="block",y){let{text:t,state:n}=G(y);e.textContent=t,P(e,n),B=performance.now();return}$(e)}}function ke(){x=!1;let e=document.getElementById(z);e&&(e.style.display="none")}function N(){if(y=null,w=null,m!==null&&(clearTimeout(m),m=null),!x)return;let e=I();e&&$(e)}function V(){if(!x)return;let e=I();if(e){if(e.style.display="block",y){let{text:t,state:n}=G(y);e.textContent=t,P(e,n),B=performance.now();return}$(e)}}function ae(e){e?He():ke()}var Oe=['[data-testid="conversation-turn"]',"[data-message-id]","[data-message-author-role]","article"];function Be(e){for(let t of Oe)if(e.querySelector(t))return!0;return!1}function ue(e){let t=e.querySelector("main");return t?!Be(t):!1}var Y="lightsession-user-collapse-styles",W="data-ls-uc-processed",p="data-ls-uc-state",C='[data-message-author-role="user"][data-message-id]',Re="[data-message-author-role][data-message-id]",ge=".user-message-bubble-color",Ue=[".whitespace-pre-wrap",".markdown.prose",".markdown",".prose"],me=240,Ie=120;function Pe(){let e=location.hostname;return e==="chatgpt.com"||e==="chat.openai.com"}function Ne(){if(document.getElementById(Y))return;let e=document.createElement("style");e.id=Y,e.textContent=`

`);return t?s.includes(t):!!(s.includes("LS:")||s.includes("light-session"))}function We(e){if(typeof e!="object"||e===null)return!1;let t=e;return typeof t.totalBefore=="number"&&typeof t.keptAfter=="number"&&typeof t.removed=="number"&&typeof t.limit=="number"}var S=null,ve=!1,ye=!1,K=null,J=null,E=null;function Z(e){let t={enabled:e.enabled,limit:e.keep,debug:e.debug},n=JSON.stringify(t);window.dispatchEvent(new CustomEvent("lightsession-config",{detail:n})),d("Dispatched config to page script:",t)}function je(e){let t=e.detail;if(!We(t)){T("Invalid trim status received:",t);return}d("Received trim status:",t),le({totalMessages:t.totalBefore,visibleMessages:t.keptAfter,trimmedMessages:t.removed,keepLastN:t.limit})}function Ke(){ve=!0,M("Fetch proxy is ready"),S&&Z(S)}function Je(){ve||T("Fetch proxy did not signal ready within timeout")}function Te(e){let t=S;S=e,oe(e.debug),Z(e),ae(e.showStatusBar&&e.enabled),t&&t.enabled!==e.enabled&&N(),Ze(e.ultraLean),e.enabled&&e.collapseLongUserMessages?(E||(E=he()),E.enable()):E&&(E.teardown(),E=null),d("Settings applied:",e)}function Ze(e){e?document.documentElement.classList.add("ls-ultra-lean"):document.documentElement.classList.remove("ls-ultra-lean")}function Qe(e,t){if(t!=="local"||!e.ls_settings?.newValue)return;let n=O(e.ls_settings.newValue);M("Settings changed via storage:",n),q(n),Te(n)}function et(){let e=location.href,t=!1,n=l=>{t||(t=!0,queueMicrotask(()=>{t=!1,e=location.href,d(`${l} navigation:`,e),N(),V(),S?.enabled&&S.collapseLongUserMessages&&E?.enable()}))},s="__lightsession_patched_history__",o=window;if(o[s]===!0)return;o[s]=!0,window.addEventListener("popstate",()=>{location.href!==e&&n("popstate")});let i=history.pushState.bind(history),L=history.replaceState.bind(history);history.pushState=function(...l){let b=i(...l);return location.href!==e&&n("pushState"),b},history.replaceState=function(...l){let b=L(...l);return location.href!==e&&n("replaceState"),b}}function tt(){let e=ue(document);e&&!ye&&(N(),V()),ye=e}function Ee(){K===null&&(K=window.setTimeout(()=>{K=null,tt()},200))}function nt(){J||(J=new MutationObserver(()=>{Ee()}),J.observe(document.documentElement,{childList:!0,subtree:!0}),Ee())}function ot(){window.addEventListener("lightsession-status",(e=>{je(e)})),window.addEventListener("message",e=>{if(e.origin!==location.origin)return;e.data?.type==="lightsession-proxy-ready"&&Ke()}),window.addEventListener("lightsession-request-config",()=>{S&&Z(S)}),A.storage.onChanged.addListener(Qe)}async function Le(){try{M("LightSession content script initializing..."),ot();let e=await re();M("Loaded settings:",e),q(e),Te(e),et(),nt(),setTimeout(Je,H.PROXY_READY_TIMEOUT_MS),M("LightSession content script initialized")}catch(e){g("Failed to initialize:",e)}}document.readyState==="loading"?document.addEventListener("DOMContentLoaded",()=>{Le().catch(e=>{g("Initialization failed:",e)})}):Le().catch(e=>{g("Initialization failed:",e)});window.addEventListener("error",e=>{(e.message?.includes("LS:")||e.filename?.includes("light-session"))&&(g("Unhandled error:",e.error||e.message),e.preventDefault())});window.addEventListener("unhandledrejection",e=>{let t;try{t=A?.runtime?.getURL?.("")}catch{t=void 0}let n=j(e.reason,t),s=j(e.reason);(n||s)&&(g("Unhandled promise rejection:",e.reason),n&&e.preventDefault())});})();

These are the 2 lines that show up with the error.

What happens over time is when a chat gets too big and upon reload, the bottom bar where you type on will either vanish entirely or the text will appear for a second and then disappear where you can't type anymore

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions