@@ -34,7 +34,7 @@ export abstract class DuckDBBrowserBindings extends DuckDBBindingsBase {
34
34
}
35
35
36
36
/** Instantiate the wasm module */
37
- protected instantiateWasm (
37
+ protected async instantiateWasm (
38
38
// eslint-disable-next-line @typescript-eslint/explicit-module-boundary-types
39
39
imports : any ,
40
40
success : ( instance : WebAssembly . Instance , module : WebAssembly . Module ) => void ,
@@ -92,9 +92,9 @@ export abstract class DuckDBBrowserBindings extends DuckDBBindingsBase {
92
92
93
93
const initiateStreaming = async ( ) => {
94
94
try {
95
- await WebAssembly . instantiateStreaming ( response , imports ) . then ( output => {
96
- success ( output . instance , output . module ) ;
97
- } ) ;
95
+ const output = await WebAssembly . instantiateStreaming ( response , imports ) ;
96
+ success ( output . instance , output . module ) ;
97
+
98
98
} catch ( error : any ) {
99
99
this . logger . log ( {
100
100
timestamp : new Date ( ) ,
@@ -105,21 +105,21 @@ export abstract class DuckDBBrowserBindings extends DuckDBBindingsBase {
105
105
value : 'Failed to instantiate WASM: ' + error ,
106
106
} ) ;
107
107
108
- throw new Error ( error ) ;
108
+ throw error ;
109
109
}
110
110
} ;
111
111
112
- initiateStreaming ( ) ;
112
+ await initiateStreaming ( ) ;
113
113
114
114
} else {
115
115
console . warn ( 'instantiating without progress handler since transform streams are unavailable' ) ;
116
116
const request = new Request ( this . mainModuleURL ) ;
117
117
118
118
const initiateStreaming = async ( ) => {
119
119
try {
120
- await WebAssembly . instantiateStreaming ( fetch ( request ) , imports ) . then ( output => {
121
- success ( output . instance , output . module ) ;
122
- } )
120
+ const output = await WebAssembly . instantiateStreaming ( fetch ( request ) , imports ) ;
121
+ success ( output . instance , output . module ) ;
122
+
123
123
} catch ( error : any ) {
124
124
this . logger . log ( {
125
125
timestamp : new Date ( ) ,
@@ -130,11 +130,11 @@ export abstract class DuckDBBrowserBindings extends DuckDBBindingsBase {
130
130
value : 'Failed to instantiate WASM: ' + error ,
131
131
} ) ;
132
132
133
- throw new Error ( error ) ;
133
+ throw error ;
134
134
}
135
135
} ;
136
136
137
- initiateStreaming ( ) ;
137
+ await initiateStreaming ( ) ;
138
138
139
139
}
140
140
} else if ( typeof XMLHttpRequest == 'function' ) {
0 commit comments