VoiceStudio is the open-source, fully-local ElevenLabs alternative — voice cloning, voice design, video dubbing, dictation, transcription & audiobook creation in 646 languages.
Python aiaudiobookcudadubbingelevenlabs-alternativehuggingfacelocal-firstmlxomnivoice-studiospeech-to-texttext-to-speechtranscriptiontranslatettsvoice-aivoice-cloningvoice-generationvoicestudioworkflow
fix(report-bug): bound the remaining host snapshot probes
debpalashf02445dadba1
diff --git a/electron/src/main/backend.ts b/electron/src/main/backend.tsindex 76d1f0cc9..272c84d8a 100644--- a/electron/src/main/backend.ts+++ b/electron/src/main/backend.ts@@ -32,7 +32,7 @@ import {statSync,writeFileSync,} from 'node:fs';-import { rm } from 'node:fs/promises';+import { access, rm, stat } from 'node:fs/promises';import { cpus, homedir, totalmem } from 'node:os';import { basename, dirname, isAbsolute, join, relative, resolve } from 'node:path';import { app } from 'electron';@@ -296,6 +296,32 @@ function findUv(): string | null {return null;}+/** Off-main-thread twin of findUv() for diagnostics: a stalled PATH drive must not block the event loop. */+async function findUvAsync(): Promise<string | null> {+ const usable = async (path: string) => {+ try {+ const info = await stat(path);+ if (!info.isFile() || info.size <= 0) return false;+ await access(path, constants.X_OK);+ return true;+ } catch {+ return false;+ }+ };+ if (app.isPackaged && process.resourcesPath) {+ const bundled = bundledUvPath(process.resourcesPath);+ if (await usable(bundled)) return bundled;+ }+ const names = process.platform === 'win32' ? ['uv.exe', 'uv'] : ['uv'];+ for (const dir of toolSearchDirs()) {+ for (const name of names) {+ const candidate = join(dir, name);+ if (await usable(candidate)) return candidate;+ }+ }+ return null;+}+function venvPython(root: string): string {return process.platform === 'win32'? join(root, '.venv', 'Scripts', 'python.exe')@@ -705,8 +731,7 @@ export class BackendSupervisor extends EventEmitter<{return collectHostSnapshot({runtimeProject: project,runtimePython: runtimePython(project),- uv: findUv(),- uvSearched: true,+ uv: findUvAsync,gpu: async () => {const info = (await app.getGPUInfo('basic')) as {gpuDevice?: { vendorId?: number; deviceId?: number; active?: boolean; driverVersion?: string }[];diff --git a/electron/src/main/host-snapshot-disk.test.ts b/electron/src/main/host-snapshot-disk.test.tsnew file mode 100644index 000000000..d486c591d--- /dev/null+++ b/electron/src/main/host-snapshot-disk.test.ts@@ -0,0 +1,22 @@+import { expect, it, vi } from 'vitest';+import { collectHostSnapshot } from './host-snapshot';++const fail = (code: string) => Object.assign(new Error(code), { code });+const ok = { bavail: 1000, bsize: 1024 ** 3 };+const run = (statfs: unknown) =>+ collectHostSnapshot({+ runtimeProject: '/a/b/c',+ runtimePython: null,+ uv: null,+ statfs: statfs as never,+ });++it('does not borrow a parent filesystem when the path exists but is unreadable', async () => {+ const statfs = vi.fn().mockRejectedValueOnce(fail('EACCES')).mockResolvedValue(ok);+ expect((await run(statfs)).diskFreeGb).toBeNull();+});++it('walks to the parent only when the path is absent', async () => {+ const statfs = vi.fn().mockRejectedValueOnce(fail('ENOENT')).mockResolvedValue(ok);+ expect((await run(statfs)).diskFreeGb).toBe(1000);+});diff --git a/electron/src/main/host-snapshot.test.ts b/electron/src/main/host-snapshot.test.tsindex 7ee800b75..787b2d132 100644--- a/electron/src/main/host-snapshot.test.ts+++ b/electron/src/main/host-snapshot.test.ts@@ -79,8 +79,7 @@ it('reports uv missing only when the search completed with no result', async ()const searched = await collectHostSnapshot({runtimeProject: null,runtimePython: null,- uv: null,- uvSearched: true,+ uv: async () => null,});const unchecked = await collectHostSnapshot({runtimeProject: null,@@ -96,3 +95,18 @@ it('validates the caller before the host snapshot IPC reads anything', () => {const handler = source.split('CHANNELS.backendHostSnapshot,')[1]?.split('ipcMain.handle')[0] ?? '';expect(handler).toContain('assertTrustedMainFrame(event, ');});++it('does not let a hung tool search or stat stall the snapshot', async () => {+ const hungSearch = await collectHostSnapshot({+ runtimeProject: null,+ runtimePython: null,+ uv: () => new Promise(() => {}),+ });+ expect(hungSearch.runtime.uvPresent).toBeNull();+ const found = await collectHostSnapshot({+ runtimeProject: null,+ runtimePython: null,+ uv: async () => '/usr/bin/uv',+ });+ expect(found.runtime.uvPresent).toBe(true);+}, 8000);diff --git a/electron/src/main/host-snapshot.ts b/electron/src/main/host-snapshot.tsindex 8001aa2b4..2a0ee3bab 100644--- a/electron/src/main/host-snapshot.ts+++ b/electron/src/main/host-snapshot.ts@@ -21,10 +21,11 @@ export interface HostSnapshotInput {/** Runtime project directory (holds `.venv`); null when it cannot be resolved. */runtimeProject: string | null;runtimePython: string | null;- uv: string | null;- /** True when the uv search completed, so a null `uv` means "not installed". */- uvSearched?: boolean;+ /** A path, or an async search: a completed search with no result means "not installed". */+ uv: string | null | (() => Promise<string | null>);gpu?: () => Promise<string | null>;+ /** Test seam for the filesystem stats call. */+ statfs?: typeof statfs;}/**@@ -58,15 +59,18 @@ async function exists(path: string | null): Promise<boolean | null> {}}-async function freeGb(path: string | null): Promise<number | null> {+async function freeGb(path: string | null, statfsFn: typeof statfs = statfs): Promise<number | null> {if (!path) return null;// First run: the project dir does not exist yet, but its drive does.let probe = path;for (;;) {try {- const fs = await statfs(probe);+ const fs = await statfsFn(probe);return Math.round(((fs.bavail * fs.bsize) / 1024 ** 3) * 10) / 10;- } catch {+ } catch (error) {+ // Only a missing path borrows its parent; an unreadable one stays unknown.+ const code = (error as NodeJS.ErrnoException).code;+ if (code !== 'ENOENT' && code !== 'ENOTDIR') return null;const parent = dirname(probe);if (parent === probe) return null;probe = parent;@@ -90,14 +94,34 @@ async function withTimeout<T>(task: Promise<T>, ms: number): Promise<T | null> {}}+const TIMED_OUT = Symbol('timed-out');++async function uvPresence(uv: HostSnapshotInput['uv']): Promise<boolean | null> {+ if (typeof uv !== 'function') return withTimeout(exists(uv), 1500);+ let timer: NodeJS.Timeout | undefined;+ try {+ const found = await Promise.race([+ uv(),+ new Promise<typeof TIMED_OUT>((resolve) => {+ timer = setTimeout(() => resolve(TIMED_OUT), 1500);+ }),+ ]);+ return found === TIMED_OUT ? null : found !== null;+ } catch {+ return null;+ } finally {+ clearTimeout(timer);+ }+}+/** Machine and runtime facts read in the main process, so a bug report is* useful even when the backend never started and `/system/info` is unreachable. */export async function collectHostSnapshot(input: HostSnapshotInput): Promise<HostSnapshot> {const platform = input.platform ?? process.platform;const [pythonPresent, uvPresent, diskFreeGb, gpu] = await Promise.all([withTimeout(exists(input.runtimePython), 1500),- input.uv ? exists(input.uv) : Promise.resolve(input.uvSearched ? false : null),- withTimeout(freeGb(input.runtimeProject), 1500),+ uvPresence(input.uv),+ withTimeout(freeGb(input.runtimeProject, input.statfs), 1500),input.gpu ? withTimeout(input.gpu(), 1500) : Promise.resolve(null),]);return {