AykutSarac/jsoncrack.com · error
Unable to process the request.
Error message
Unable to process the request.
What it means
Toast from useJsonQuery.updateJson when the jq-web pipeline fails. The function dynamically imports jq-web, calls JSON.parse(getJson()) then jq.promised.json(parsed, query). Any failure — module/WASM load error, invalid JSON input, or an invalid jq query — is caught and reported as 'Unable to process the request.' console.error(error) logs the real cause.
Source
Thrown at apps/www/src/hooks/useJsonQuery.ts:23
const useJsonQuery = () => {
const getJson = useJson(state => state.getJson);
const setContents = useFile(state => state.setContents);
const transformer = async ({ value }) => {
const { run } = await import("json_typegen_wasm");
return run("Root", value, JSON.stringify({ output_mode: "typescript/typealias" }));
};
const updateJson = async (query: string, cb?: () => void) => {
try {
const jq = await import("jq-web");
const res = await jq.promised.json(JSON.parse(getJson()), query);
setContents({ contents: JSON.stringify(res, null, 2) });
cb?.();
} catch (error) {
console.error(error);
toast.error("Unable to process the request.");
}
};
const getJsonType = async () => {
const types = await transformer({ value: getJson() });
return types;
};
return { updateJson, getJsonType };
};
export default useJsonQuery;
View on GitHub (pinned to 3c9af69e23)
Solutions
- Validate the editor JSON parses before running jq (pre-check with JSON.parse).
- Verify jq-web's WASM asset is served correctly (check Network tab for a 200 on the .wasm).
- Allow 'wasm-src' / 'script-src' in CSP if the WASM fails to compile.
- Surface the real error message (jq-web often returns a parse error with position) instead of the generic text.
Example fix
// before
} catch (error) {
console.error(error);
toast.error("Unable to process the request.");
}
// after — distinguish parse, jq-syntax, and load failures
} catch (error) {
console.error(error);
const msg = error instanceof SyntaxError && /JSON/.test(error.message)
? "Editor content is not valid JSON."
: (error?.message?.includes("compile") || error?.message?.includes("wasm"))
? "jq engine failed to load."
: "Invalid jq query or unable to process.";
toast.error(msg);
} Defensive patterns
Strategy: validation
Validate before calling
// Validate JSON parses before invoking jq
export function isParsableJson(text: string): boolean {
try { JSON.parse(text); return true; } catch { return false; }
} Type guard
// Detect jq-web module-load/WASM failures
export function isJqLoadError(error: unknown): boolean {
const msg = error instanceof Error ? error.message : String(error);
return /wasm|compile|instantiate|import/i.test(msg);
} Try / catch
// Distinguish parse, load, and query errors
if (!isParsableJson(getJson())) { toast.error("Editor content is not valid JSON."); return; }
try { const res = await jq.promised.json(JSON.parse(getJson()), query); /* ... */ }
catch (error) {
console.error(error);
toast.error(isJqLoadError(error) ? "jq engine failed to load." : "Invalid jq query.");
} Prevention
- Ensure jq-web's .wasm asset is served and CSP allows wasm-src.
- Validate editor JSON before running jq.
- Surface the real jq error (often includes position) instead of a generic message.
When it happens
Trigger: Typing an invalid jq expression (e.g. `.foo |`, `.[`, unknown functions); running jq against editor content that is not valid JSON (JSON.parse throws); jq-web WASM failing to load/instantiate (missing .wasm asset, CSP blocking wasm, memory).
Common situations: User learning jq syntax; CDN/bundler misconfiguration dropping jq-web's .wasm file; Content-Security-Policy without wasm-src; running jq on a large payload exceeding the WASM heap.
Related errors
- error.message
- error
- Unable to load graph renderer.
- Failed to parse data (${syntaxErrorCount} syntax error(s)).
- Unable to parse data.
AI-assisted analysis of AykutSarac/jsoncrack.com@3c9af69e23 (2026-08-12).
Data as JSON: /api/errors/2dcc91a99bf71bd7.
Report an issue: GitHub.