aboutsummaryrefslogtreecommitdiff
path: root/ext/wasm/api/sqlite3-opfs-async-proxy.js
diff options
context:
space:
mode:
authorstephan <stephan@noemail.net>2023-05-30 14:10:28 +0000
committerstephan <stephan@noemail.net>2023-05-30 14:10:28 +0000
commit73d806dc1f38f1164a6f52187fb43336fde865b7 (patch)
tree4b67a0c50ffb30a52d28aba28af6c245bdeb3e6d /ext/wasm/api/sqlite3-opfs-async-proxy.js
parente32fef140006c864e63a535bd718d7d19cef11bb (diff)
downloadsqlite-73d806dc1f38f1164a6f52187fb43336fde865b7.tar.gz
sqlite-73d806dc1f38f1164a6f52187fb43336fde865b7.zip
Minor tweak to the OPFS async proxy to attempt to account for a spurious high-load console error message which was reported via the sqlite-wasm npm project.
FossilOrigin-Name: a61467d1fbb7a2804bfdc685a38e0b738747b9afd42c25a78a938b114a822f61
Diffstat (limited to 'ext/wasm/api/sqlite3-opfs-async-proxy.js')
-rw-r--r--ext/wasm/api/sqlite3-opfs-async-proxy.js17
1 files changed, 16 insertions, 1 deletions
diff --git a/ext/wasm/api/sqlite3-opfs-async-proxy.js b/ext/wasm/api/sqlite3-opfs-async-proxy.js
index ddcad8f61..179a81635 100644
--- a/ext/wasm/api/sqlite3-opfs-async-proxy.js
+++ b/ext/wasm/api/sqlite3-opfs-async-proxy.js
@@ -818,9 +818,24 @@ const installAsyncProxy = function(self){
}
while(!flagAsyncShutdown){
try {
- if('timed-out'===Atomics.wait(
+ if('not-equal'!==Atomics.wait(
state.sabOPView, state.opIds.whichOp, 0, state.asyncIdleWaitTime
)){
+ /* Maintenance note: we compare against 'not-equal' because
+
+ https://github.com/tomayac/sqlite-wasm/issues/12
+
+ is reporting that this occassionally, under high loads,
+ returns 'ok', which leads to the whichOp being 0 (which
+ isn't a valid operation ID and leads to an exception,
+ along with a corresponding ugly console log
+ message). Unfortunately, the conditions for that cannot
+ be reliably reproduced. The only place in our code which
+ writes a 0 to the state.opIds.whichOp SharedArrayBuffer
+ index is a few lines down from here, and that instance
+ is required in order for clear communication between
+ the sync half of this proxy and this half.
+ */
await releaseImplicitLocks();
continue;
}