UNPKG

openclaw

Version:

Multi-channel AI gateway with extensible messaging integrations

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