@@ -89,15 +89,47 @@ export abstract class DuckDBBrowserBindings extends DuckDBBindingsBase {
89
89
} ;
90
90
// Instantiate streaming
91
91
const response = fetchWithProgress ( ) ;
92
- WebAssembly . instantiateStreaming ( response , imports ) . then ( output => {
93
- success ( output . instance , output . module ) ;
94
- } ) ;
92
+
93
+ const initiateStreaming = async ( ) => {
94
+ await WebAssembly . instantiateStreaming ( response , imports ) . then ( output => {
95
+ success ( output . instance , output . module ) ;
96
+ } ) . catch ( error => {
97
+ this . logger . log ( {
98
+ timestamp : new Date ( ) ,
99
+ level : LogLevel . ERROR ,
100
+ origin : LogOrigin . BINDINGS ,
101
+ topic : LogTopic . INSTANTIATE ,
102
+ event : LogEvent . ERROR ,
103
+ value : 'Failed to instantiate WASM: ' + error ,
104
+ } ) ;
105
+ throw new Error ( error ) ;
106
+ } ) ;
107
+ } ;
108
+
109
+ initiateStreaming ( ) ;
110
+
95
111
} else {
96
112
console . warn ( 'instantiating without progress handler since transform streams are unavailable' ) ;
97
113
const request = new Request ( this . mainModuleURL ) ;
98
- WebAssembly . instantiateStreaming ( fetch ( request ) , imports ) . then ( output => {
99
- success ( output . instance , output . module ) ;
100
- } ) ;
114
+
115
+ const initiateStreaming = async ( ) => {
116
+ await WebAssembly . instantiateStreaming ( fetch ( request ) , imports ) . then ( output => {
117
+ success ( output . instance , output . module ) ;
118
+ } ) . catch ( error => {
119
+ this . logger . log ( {
120
+ timestamp : new Date ( ) ,
121
+ level : LogLevel . ERROR ,
122
+ origin : LogOrigin . BINDINGS ,
123
+ topic : LogTopic . INSTANTIATE ,
124
+ event : LogEvent . ERROR ,
125
+ value : 'Failed to instantiate WASM: ' + error ,
126
+ } ) ;
127
+ throw new Error ( error ) ;
128
+ } ) ;
129
+ } ;
130
+
131
+ initiateStreaming ( ) ;
132
+
101
133
}
102
134
} else if ( typeof XMLHttpRequest == 'function' ) {
103
135
// Otherwise we fall back to XHRs
0 commit comments