https://domlink.deployments.hotsocket.fyi/

issuesearch: Added timeout for record retrieval

+12 -10
+3 -3
flake.nix
··· 10 10 pkgs = (import (inputs.nixpkgs) { inherit system; }); 11 11 in { 12 12 devShell = pkgs.mkShell { 13 - buildInputs=[ 14 - pkgs.deno 13 + buildInputs = with pkgs; [ 14 + deno rsync 15 15 ]; 16 16 }; 17 17 } 18 18 ); 19 - } 19 + }
+2 -2
package.json
··· 15 15 }, 16 16 "scripts": { 17 17 "serve": "http-server ./out -C", 18 - "build": "deno bundle src/* --outdir=out && rsync -av static/ out/", 19 - "build-prod": "esbuild src/* --minify --tree-shaking=true --bundle --outdir=out && rsync -av static/ out/" 18 + "build": "deno bundle --platform=browser src/* --outdir=out --sourcemap=inline && rsync -av static/ out/", 19 + "build-prod": "deno bundle --platform=browser src/* --outdir=out --minify && rsync -av static/ out/" 20 20 } 21 21 }
+7 -5
src/issuesearch.ts
··· 85 85 if (nextCursor == null) break; 86 86 } 87 87 allIssues = (await Promise.all(allIssueRefs.map(async (issueRef) => { 88 - let rsp = await xcall(SLINGSHOT, "com.atproto.repo.getRecord", { 88 + let rsp = await Promise.race([(xcall(SLINGSHOT, "com.atproto.repo.getRecord", { 89 89 repo: issueRef.did, 90 90 collection: issueRef.collection, 91 91 rkey: issueRef.rkey 92 - }) as slingshotResponse<issueRecord>; 92 + }) as slingshotResponse<issueRecord>), new Promise((resolve,_)=>{setTimeout(resolve, 2000, null);})]); 93 + if (rsp == null) { 94 + console.log(`getRecord timed out: at://${issueRef.did}/${issueRef.collection}/${issueRef.rkey}`); 95 + return null; 96 + } 93 97 let issue = rsp.value; 94 98 let doc; 95 99 try { ··· 150 154 searchRow.style(x=>x.display="none"); 151 155 try { 152 156 await getIssues(repoUrl.value); 153 - console.log(allIssues); 154 157 last = renderIssues(allIssues); 155 158 searchRow.style(x=>x.removeProperty("display")); 156 159 } catch (e) { 157 160 last = new Label("Failed"); 158 - console.log(e); 161 + console.error(e); 159 162 } 160 163 Body.add(last); 161 164 searchInput.value = ""; 162 - console.log(last); 163 165 (runButton.wraps as HTMLButtonElement).disabled = false; 164 166 }); 165 167