diff options
author | stephan <stephan@noemail.net> | 2024-07-11 19:50:17 +0000 |
---|---|---|
committer | stephan <stephan@noemail.net> | 2024-07-11 19:50:17 +0000 |
commit | 8ee747dda55887775417e13882ffed29868a0865 (patch) | |
tree | d2e66d89a31caebabdee244604041ae686bfa581 /ext/wasm/api/sqlite3-vfs-opfs-sahpool.c-pp.js | |
parent | 9958c51a5d9b151aab4b5e6c1dd18188e94e99b6 (diff) | |
download | sqlite-8ee747dda55887775417e13882ffed29868a0865.tar.gz sqlite-8ee747dda55887775417e13882ffed29868a0865.zip |
Reformulate the forceReinitIfFailed handling based on feedback, to correct the type-checking and resolve a potential race condition.
FossilOrigin-Name: c4f468309158f9b951137461213fb269d96d15c331256cf392a56c9bed231460
Diffstat (limited to 'ext/wasm/api/sqlite3-vfs-opfs-sahpool.c-pp.js')
-rw-r--r-- | ext/wasm/api/sqlite3-vfs-opfs-sahpool.c-pp.js | 16 |
1 files changed, 11 insertions, 5 deletions
diff --git a/ext/wasm/api/sqlite3-vfs-opfs-sahpool.c-pp.js b/ext/wasm/api/sqlite3-vfs-opfs-sahpool.c-pp.js index 199ac7d61..2a0471e25 100644 --- a/ext/wasm/api/sqlite3-vfs-opfs-sahpool.c-pp.js +++ b/ext/wasm/api/sqlite3-vfs-opfs-sahpool.c-pp.js @@ -1225,13 +1225,19 @@ globalThis.sqlite3ApiBootstrap.initializers.push(function(sqlite3){ throw options.$testThrowPhase1; } if(initPromises[vfsName]){ - const p = initPromises[vfsName]; - if( (p instanceof OpfsSAHPool) || !options.forceReinitIfFailed ){ - //log("Returning cached installOpfsSAHPoolVfs() result",options,vfsName,initPromises[vfsName]); + try { + const p = await initPromises[vfsName]; + //log("installOpfsSAHPoolVfs() returning cached result",options,vfsName,p); return p; + }catch(e){ + //log("installOpfsSAHPoolVfs() got cached failure",options,vfsName,e); + if( options.forceReinitIfFailed ){ + delete initPromises[vfsName]; + /* Fall through and try again. */ + }else{ + throw e; + } } - delete initPromises[vfsName]; - /* Fall through and try again. */ } if(!globalThis.FileSystemHandle || !globalThis.FileSystemDirectoryHandle || |