UNPKG

openclaw

Version:

Multi-channel AI gateway with extensible messaging integrations

1 lines • 1.86 kB
import{o as e}from"./sqlite-readonly-runtime-process-manifest-CLhsN5hb.mjs";import{a as t}from"./sqlite-readonly-runtime-binary-BIdoCQkJ.mjs";import{r as n}from"./sqlite-readonly-runtime-worker-url-D7L1HCPF.mjs";import{join as r}from"node:path";import{setImmediate as i}from"node:timers/promises";import{mkdtemp as a,realpath as o,rm as s}from"node:fs/promises";import{tmpdir as c}from"node:os";import{Worker as l}from"node:worker_threads";import{channel as u}from"node:diagnostics_channel";const d=u(`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 i(void 0,{ref:!r})),n&&await s(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,i,s,u;try{e=await a(r(c(),`openclaw-sqlite-close-`)),e=await o(e),d.publish({phase:`start`}),i=new l(n(t.sqliteCloseProbe),{workerData:e,execArgv:[]});let f=i;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})`))),s=setTimeout(()=>t(/* @__PURE__ */ Error(`SQLite close check timed out after 10000ms`)),1e4)})}catch(e){u={explicitSqliteCloseReleasesNativeResources:!1,reason:String(e)}}finally{clearTimeout(s)}let f=!u.explicitSqliteCloseReleasesNativeResources,p=cleanupProbe(i,e,f);if(f)return u;let m=await p;return m?{explicitSqliteCloseReleasesNativeResources:!1,reason:m}:u}export{probeSqliteNativeClose};