@rig-c/review 1.5.1 → 1.5.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +1 -1
- package/src/front.ts +3 -1
package/package.json
CHANGED
package/src/front.ts
CHANGED
|
@@ -164,7 +164,9 @@ export function startFront(options:{control:string;port:number;nonce:string;fing
|
|
|
164
164
|
}});
|
|
165
165
|
return {origin,stop:()=>server.stop(true),idleMs:()=>performance.now()-last,active:()=>active};
|
|
166
166
|
}
|
|
167
|
-
|
|
167
|
+
/** A missing directory or record means gone; any other read error (readdir or a record) throws, and the caller keeps
|
|
168
|
+
* the front up. A record read that failed with EACCES or ENOTDIR used to count as gone and stopped the front (#354). */
|
|
169
|
+
async function liveInstances(control:string):Promise<boolean>{let names:string[];try{names=await readdir(control);}catch(e){if((e as NodeJS.ErrnoException).code==='ENOENT')return false;throw e;}for(const name of names){if(/^[a-f0-9]{64}\.claim$/.test(name))return true;if(/^[a-f0-9]{64}\.json$/.test(name)){const row=await readRecord(join(control,name),name.slice(0,64));if(row&&running(row.pid))return true;}}return false;}
|
|
168
170
|
export async function runFront(requestPath:string):Promise<void>{
|
|
169
171
|
const spec=await smallJson(requestPath) as FrontRequest;if(spec?.schema!=='rig-review-front-request/1'||!uuid.test(spec.nonce??'')||!hex64.test(spec.fingerprint??'')||!Number.isSafeInteger(spec.port)||spec.port<1||spec.port>65535||!Number.isSafeInteger(spec.idleMs)||spec.idleMs<100)throw new Error('front: invalid request');
|
|
170
172
|
const control=await realpath(spec.control);if(dirname(await realpath(requestPath))!==control||spec.request!==requestPath||spec.record!==join(control,frontName(spec.port)+'.json'))throw new Error('front: invalid state locations');
|