Skip to content
This repository was archived by the owner on Mar 3, 2025. It is now read-only.

Commit e210cdb

Browse files
vpbs2ujaval403
authored andcommitted
resolve: comments
1 parent 44f6f8d commit e210cdb

File tree

2 files changed

+16
-10
lines changed

2 files changed

+16
-10
lines changed

packages/duckdb-wasm/src/bindings/bindings_browser_base.ts

Lines changed: 14 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -91,9 +91,11 @@ export abstract class DuckDBBrowserBindings extends DuckDBBindingsBase {
9191
const response = fetchWithProgress();
9292

9393
const initiateStreaming = async () => {
94-
await WebAssembly.instantiateStreaming(response, imports).then(output => {
95-
success(output.instance, output.module);
96-
}).catch(error => {
94+
try{
95+
await WebAssembly.instantiateStreaming(response, imports).then(output => {
96+
success(output.instance, output.module);
97+
});
98+
} catch (error: any) {
9799
this.logger.log({
98100
timestamp: new Date(),
99101
level: LogLevel.ERROR,
@@ -102,8 +104,9 @@ export abstract class DuckDBBrowserBindings extends DuckDBBindingsBase {
102104
event: LogEvent.ERROR,
103105
value: 'Failed to instantiate WASM: ' + error,
104106
});
107+
105108
throw new Error(error);
106-
});
109+
}
107110
};
108111

109112
initiateStreaming();
@@ -113,9 +116,11 @@ export abstract class DuckDBBrowserBindings extends DuckDBBindingsBase {
113116
const request = new Request(this.mainModuleURL);
114117

115118
const initiateStreaming = async () => {
116-
await WebAssembly.instantiateStreaming(fetch(request), imports).then(output => {
117-
success(output.instance, output.module);
118-
}).catch(error => {
119+
try {
120+
await WebAssembly.instantiateStreaming(fetch(request), imports).then(output => {
121+
success(output.instance, output.module);
122+
})
123+
} catch (error: any){
119124
this.logger.log({
120125
timestamp: new Date(),
121126
level: LogLevel.ERROR,
@@ -124,8 +129,9 @@ export abstract class DuckDBBrowserBindings extends DuckDBBindingsBase {
124129
event: LogEvent.ERROR,
125130
value: 'Failed to instantiate WASM: ' + error,
126131
});
132+
127133
throw new Error(error);
128-
});
134+
}
129135
};
130136

131137
initiateStreaming();

packages/duckdb-wasm/src/bindings/bindings_browser_eh.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,12 +17,12 @@ export class DuckDB extends DuckDBBrowserBindings {
1717
}
1818

1919
/** Instantiate the bindings */
20-
protected instantiateImpl(moduleOverrides: Partial<DuckDBModule>): Promise<DuckDBModule> {
20+
protected async instantiateImpl(moduleOverrides: Partial<DuckDBModule>): Promise<DuckDBModule> {
2121
try{
2222
const wasm = this.instantiateWasm.bind(this);
2323
const locateFile = this.locateFile.bind(this);
2424

25-
return DuckDBWasm({
25+
return await DuckDBWasm({
2626
...moduleOverrides,
2727
instantiateWasm: wasm,
2828
locateFile: locateFile,

0 commit comments

Comments
 (0)