openclaw
Version:
Multi-channel AI gateway with extensible messaging integrations
1 lines • 1.83 kB
JavaScript
import{i as e}from"./transcript-src-gRxwdYZM.mjs";import{a as t}from"./transcript-runtime-binary-4JwD1Zy9.mjs";import{r as n}from"./transcript-runtime-worker-url-Bi-zitXH.mjs";import{channel as r}from"node:diagnostics_channel";import{Worker as i}from"node:worker_threads";import{join as a}from"node:path";import{mkdtemp as o,realpath as s,rm as c}from"node:fs/promises";import{tmpdir as l}from"node:os";import{setImmediate as u}from"node:timers/promises";const d=r(`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 c(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,r,c,u;try{e=await o(a(l(),`openclaw-sqlite-close-`)),e=await s(e),d.publish({phase:`start`}),r=new i(n(t.sqliteCloseProbe),{workerData:e,execArgv:[]});let f=r;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(r,e,f);if(f)return u;let m=await p;return m?{explicitSqliteCloseReleasesNativeResources:!1,reason:m}:u}export{probeSqliteNativeClose};