Skip to content

Commit

Permalink
Worker runtime: avoid errors in JSON.parse to bubble up
Browse files Browse the repository at this point in the history
  • Loading branch information
carlopi committed Feb 29, 2024
1 parent f11c8df commit 98daef7
Showing 1 changed file with 10 additions and 5 deletions.
15 changes: 10 additions & 5 deletions packages/duckdb-wasm/src/bindings/runtime_browser.ts
Original file line number Diff line number Diff line change
Expand Up @@ -44,13 +44,18 @@ export const BROWSER_RUNTIME: DuckDBRuntime & {
}
const infoStr = readString(mod, d, n);
dropResponseBuffers(mod);
const info = JSON.parse(infoStr);
if (info == null) {
try {
const info = JSON.parse(infoStr);
if (info == null) {
return null;
}
const file = { ...info, blob: null } as DuckDBFileInfo;
BROWSER_RUNTIME._fileInfoCache.set(fileId, file);
return file;
} catch (error) {
console.warn(error);
return null;
}
const file = { ...info, blob: null } as DuckDBFileInfo;
BROWSER_RUNTIME._fileInfoCache.set(fileId, file);
return file;
} catch (e: any) {
console.log(e);
return null;
Expand Down

0 comments on commit 98daef7

Please sign in to comment.