openclaw
Version:
Multi-channel AI gateway with extensible messaging integrations
1 lines • 1.79 kB
JavaScript
import{r as e}from"./git-operation.worker-src-D09IpTfC.mjs";import{l as t,r as n}from"./git-operation.worker-runtime-worker-url-Cj02s2_u.mjs";import{mkdtemp as r,realpath as i,rm as a}from"node:fs/promises";import{join as o}from"node:path";import{tmpdir as s}from"node:os";import{channel as c}from"node:diagnostics_channel";import{Worker as l}from"node:worker_threads";import{setImmediate as u}from"node:timers/promises";const d=c(`openclaw.sqlite.close-probe`);async function cleanupProbe(t,n,r){try{t&&(r&&t.unref(),await e(t.terminate(),5e3,()=>{throw Error(`SQLite close check termination timed out after 5000ms`)},{ref:!r}),await u(void 0,{ref:!r})),n&&await a(n,{recursive:!0,force:!0})}catch(e){t?.unref();let r=`SQLite close check cleanup failed: ${String(e)}; retained ${n}`;return process.emitWarning(r,{code:`SQLITE_CLOSE_PROBE_CLEANUP`}),r}}async function probeSqliteNativeClose(){let e,a,c,u;try{e=await r(o(s(),`openclaw-sqlite-close-`)),e=await i(e),d.publish({phase:`start`}),a=new l(n(t.sqliteCloseProbe),{workerData:e,execArgv:[]});let f=a;u=await new Promise((e,t)=>{f.once(`message`,n=>{typeof n==`string`?e({explicitSqliteCloseReleasesNativeResources:n===``,reason:n||`Native close check passed`}):t(/* @__PURE__ */ Error(`Invalid SQLite close check reply`))}),f.once(`error`,t),f.once(`exit`,e=>t(/* @__PURE__ */ Error(`SQLite close check exited before its reply (${e})`))),c=setTimeout(()=>t(/* @__PURE__ */ Error(`SQLite close check timed out after 10000ms`)),1e4)})}catch(e){u={explicitSqliteCloseReleasesNativeResources:!1,reason:String(e)}}finally{clearTimeout(c)}let f=!u.explicitSqliteCloseReleasesNativeResources,p=cleanupProbe(a,e,f);if(f)return u;let m=await p;return m?{explicitSqliteCloseReleasesNativeResources:!1,reason:m}:u}export{probeSqliteNativeClose};