janhq/jan · error · Error
response.statusText
Error message
response.statusText
What it means
This error is thrown when fetching an audio file via the Tauri convertFileSrc protocol returns a non-ok HTTP response. convertFileSrc converts a local filesystem path to a tauri:// or http://localhost URL that the webview can fetch. A non-ok response means the Tauri asset protocol handler could not serve the file. The error message is response.statusText, which may be empty under HTTP/2 (no statusText) or when the webview returns a bare status code.
Source
Thrown at web-app/src/containers/ChatInput.tsx:1291
if (textareaRef.current) textareaRef.current.focus()
}
const openAudioPicker = useCallback(async () => {
if (isPlatformTauri()) {
try {
const selected = await serviceHub.dialog().open({
multiple: true,
filters: [{ name: 'Audio', extensions: ['wav', 'mp3'] }],
})
if (selected) {
const paths = Array.isArray(selected) ? selected : [selected]
const files: File[] = []
for (const path of paths) {
try {
const { convertFileSrc } = await import('@tauri-apps/api/core')
const fileUrl = convertFileSrc(path)
const response = await fetch(fileUrl)
if (!response.ok) throw new Error(response.statusText)
const blob = await response.blob()
const fileName = path.split(/[\\/]/).filter(Boolean).pop() || 'audio'
const ext = fileName.toLowerCase().split('.').pop()
const mimeType = ext === 'mp3' ? 'audio/mpeg' : 'audio/wav'
files.push(new File([blob], fileName, { type: mimeType }))
} catch (error) {
console.error('Failed to read audio file:', error)
toast.error('Failed to read audio file', {
description: error instanceof Error ? error.message : String(error),
})
}
}
if (files.length > 0) await processAudioFiles(files)
}
} catch (error) {
console.error('Failed to open audio dialog:', error)
}
if (textareaRef.current) textareaRef.current.focus()View on GitHub (pinned to fad3f12a14)
Solutions
- Verify the file exists and is readable before calling fetch: use fs.exists via Tauri API.
- Expand the asset protocol scope in tauri.conf.json security.assetProtocol.scope.
- Handle empty statusText by including the status code in the error message.
- On macOS, ensure the app has the necessary file access entitlements.
Example fix
// before
const response = await fetch(fileUrl)
if (!response.ok) throw new Error(response.statusText)
// after
const response = await fetch(fileUrl)
if (!response.ok) {
throw new Error(`HTTP ${response.status}: ${response.statusText || 'failed to load audio file'}`)
} Defensive patterns
Strategy: validation
Validate before calling
// Before fetching, verify the file exists via Tauri fs API
import { exists } from '@tauri-apps/plugin-fs';
if (!(await exists(path))) {
toast.error('File not found', { description: path });
continue;
}
// Or check readability:
try {
const stat = await statFile(path);
if (!stat.isFile) { throw new Error('Not a regular file'); }
} catch { toast.error('Cannot access file'); continue; } Try / catch
const response = await fetch(fileUrl);
if (!response.ok) {
throw new Error(
`HTTP ${response.status}: ${response.statusText || 'failed to load audio file'}`
);
}
// Also catch network-level fetch failures:
try {
const blob = await response.blob();
} catch (e) {
throw new Error(`Failed to read audio data: ${e instanceof Error ? e.message : e}`);
} Prevention
- Verify the file exists before fetching it via the asset protocol.
- Expand the assetProtocol.scope in tauri.conf.json to include accessible directories.
- Include the HTTP status code in the error message (statusText may be empty under HTTP/2).
- On macOS, ensure the app has file access entitlements for user-selected files.
When it happens
Trigger: The selected file path no longer exists (deleted between dialog selection and fetch). File permissions deny read access. The path contains characters that break the Tauri asset protocol URL encoding. The file is on a different mount or removable media that was ejected. The webview's asset protocol scope does not include the file's directory.
Common situations: User selects a file from a USB drive that was disconnected before the fetch runs. File path with Unicode characters or spaces causing URL encoding issues. Tauri security config (tauri.conf.json security.csp or assetProtocol.scope) restricting access to certain directories. Permission denied on macOS due to App Sandbox without entitlements.
Related errors
- Failed to decompress archive: ${String(e)}
- Failed to load llamacpp backend
- Response body is null
- Failed to fetch file: ${response.statusText}
- model-errors:noRunningSession
AI-assisted analysis of janhq/jan@fad3f12a14 (2026-08-12).
Data as JSON: /api/errors/e1810f2736b75485.
Report an issue: GitHub.