@@ -34,7 +34,7 @@ export abstract class DuckDBBrowserBindings extends DuckDBBindingsBase {
3434 }
3535
3636 /** Instantiate the wasm module */
37- protected instantiateWasm (
37+ protected async instantiateWasm (
3838 // eslint-disable-next-line @typescript-eslint/explicit-module-boundary-types
3939 imports : any ,
4040 success : ( instance : WebAssembly . Instance , module : WebAssembly . Module ) => void ,
@@ -92,9 +92,9 @@ export abstract class DuckDBBrowserBindings extends DuckDBBindingsBase {
9292
9393 const initiateStreaming = async ( ) => {
9494 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+
9898 } catch ( error : any ) {
9999 this . logger . log ( {
100100 timestamp : new Date ( ) ,
@@ -105,21 +105,21 @@ export abstract class DuckDBBrowserBindings extends DuckDBBindingsBase {
105105 value : 'Failed to instantiate WASM: ' + error ,
106106 } ) ;
107107
108- throw new Error ( error ) ;
108+ throw error ;
109109 }
110110 } ;
111111
112- initiateStreaming ( ) ;
112+ await initiateStreaming ( ) ;
113113
114114 } else {
115115 console . warn ( 'instantiating without progress handler since transform streams are unavailable' ) ;
116116 const request = new Request ( this . mainModuleURL ) ;
117117
118118 const initiateStreaming = async ( ) => {
119119 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+
123123 } catch ( error : any ) {
124124 this . logger . log ( {
125125 timestamp : new Date ( ) ,
@@ -130,11 +130,11 @@ export abstract class DuckDBBrowserBindings extends DuckDBBindingsBase {
130130 value : 'Failed to instantiate WASM: ' + error ,
131131 } ) ;
132132
133- throw new Error ( error ) ;
133+ throw error ;
134134 }
135135 } ;
136136
137- initiateStreaming ( ) ;
137+ await initiateStreaming ( ) ;
138138
139139 }
140140 } else if ( typeof XMLHttpRequest == 'function' ) {
0 commit comments