mirror of
https://github.com/sqlite/sqlite.git
synced 2025-07-29 08:01:23 +03:00
js: resolve the mysterious "extra" unhandled exception notification, caused by inadvertently forking one promise into two separate ones (failing to properly reassign a then() result). Fix a typo in new Worker 1 code which caused the DB(filename) name to be incorrect.
FossilOrigin-Name: 7467ac88801224089b51c6ba7924f93283dd87beca602a186c83632df26cfc85
This commit is contained in:
@ -21,7 +21,7 @@ if('undefined' !== typeof Module){ // presumably an Emscripten build
|
||||
Install a suitable default configuration for sqlite3ApiBootstrap().
|
||||
*/
|
||||
const SABC = self.sqlite3ApiBootstrap.defaultConfig;
|
||||
SABC.Module = Module /* ==> Current needs to be exposed here for test code. NOT part
|
||||
SABC.Module = Module /* ==> Currently needs to be exposed here for test code. NOT part
|
||||
of the public API. */;
|
||||
SABC.exports = Module['asm'];
|
||||
SABC.memory = Module.wasmMemory /* gets set if built with -sIMPORT_MEMORY */;
|
||||
|
@ -180,7 +180,7 @@ sqlite3.initWorker1API = function(){
|
||||
toss("Throwing because of simulateError flag.");
|
||||
}
|
||||
if(args.persistent && args.filename){
|
||||
oargs.filaname = sqlite3.capi.sqlite3_web_persistent_dir() + args.filename;
|
||||
oargs.filename = sqlite3.capi.sqlite3_web_persistent_dir() + args.filename;
|
||||
}else if('' === args.filename){
|
||||
oargs.filename = args.filename;
|
||||
}else{
|
||||
|
@ -18,7 +18,7 @@
|
||||
slightly simpler client-side interface than the slightly-lower-level
|
||||
Worker API does.
|
||||
|
||||
This script necessarily exposes on global symbol, but clients may
|
||||
This script necessarily exposes one global symbol, but clients may
|
||||
freely `delete` that symbol after calling it.
|
||||
*/
|
||||
'use strict';
|
||||
@ -81,8 +81,8 @@
|
||||
information about messages.
|
||||
|
||||
|
||||
This function returns a stateful factory function with the following
|
||||
interfaces:
|
||||
This function returns a stateful factory function with the
|
||||
following interfaces:
|
||||
|
||||
- Promise function(messageType, messageArgs)
|
||||
- Promise function({message object})
|
||||
@ -183,7 +183,11 @@ self.sqlite3Worker1Promiser = function callee(config = callee.defaultConfig){
|
||||
default:
|
||||
break;
|
||||
}
|
||||
msgHandler.resolve(ev);
|
||||
try {
|
||||
msgHandler.resolve(ev);
|
||||
}catch(e){
|
||||
msgHandler.reject(e);
|
||||
}
|
||||
}/*worker.onmessage()*/;
|
||||
return function(/*(msgType, msgArgs) || (msg)*/){
|
||||
let msg;
|
||||
@ -214,19 +218,19 @@ self.sqlite3Worker1Promiser = function callee(config = callee.defaultConfig){
|
||||
}
|
||||
}
|
||||
//debug("requestWork", msg);
|
||||
const p = new Promise(function(resolve, reject){
|
||||
let p = new Promise(function(resolve, reject){
|
||||
proxy.resolve = resolve;
|
||||
proxy.reject = reject;
|
||||
handlerMap[msg.messageId] = proxy;
|
||||
debug("Posting",msg.type,"message to Worker dbId="+(config.dbId||'default')+':',msg);
|
||||
config.worker.postMessage(msg);
|
||||
});
|
||||
if(cbId) p.finally(()=>delete handlerMap[cbId]);
|
||||
if(cbId) p = p.finally(()=>delete handlerMap[cbId]);
|
||||
return p;
|
||||
};
|
||||
}/*sqlite3Worker1Promiser()*/;
|
||||
self.sqlite3Worker1Promiser.defaultConfig = {
|
||||
worker: ()=>new Worker('sqlite3-worker1.js'),
|
||||
onerror: console.error.bind(console),
|
||||
onerror: (...args)=>console.error('worker1 error',...args),
|
||||
dbId: undefined
|
||||
};
|
||||
|
@ -29,16 +29,6 @@
|
||||
};
|
||||
|
||||
let startTime;
|
||||
const logEventResult = async function(evd){
|
||||
logHtml(evd.errorClass ? 'error' : '',
|
||||
"response to",evd.messageId,"Worker time =",
|
||||
(evd.workerRespondTime - evd.workerReceivedTime),"ms.",
|
||||
"Round-trip event time =",
|
||||
(performance.now() - evd.departureTime),"ms.",
|
||||
(evd.errorClass ? evd.message : "")
|
||||
);
|
||||
};
|
||||
|
||||
const testCount = async ()=>{
|
||||
logHtml("","Total test count:",T.counter+". Total time =",(performance.now() - startTime),"ms");
|
||||
};
|
||||
@ -70,26 +60,28 @@
|
||||
delete self.sqlite3Worker1Promiser;
|
||||
|
||||
const wtest = async function(msgType, msgArgs, callback){
|
||||
let p = workerPromise({type: msgType, args:msgArgs});
|
||||
if(callback) p.then(callback).finally(testCount);
|
||||
return p;
|
||||
const p = workerPromise({type: msgType, args:msgArgs});
|
||||
return callback ? p.then(callback).finally(testCount) : p;
|
||||
};
|
||||
|
||||
const runTests = async function(){
|
||||
const dbFilename = '/testing2.sqlite3';
|
||||
logHtml('',
|
||||
"Sending 'open' message and waiting for its response before continuing.");
|
||||
startTime = performance.now();
|
||||
wtest('open', {
|
||||
filename:'testing2.sqlite3',
|
||||
simulateError: 0 /* if true, fail the 'open' */
|
||||
await wtest('open', {
|
||||
filename: dbFilename,
|
||||
persistent: true,
|
||||
simulateError: 0 /* if true, fail the 'open' */,
|
||||
}, function(ev){
|
||||
log("then open result",ev);
|
||||
T.assert('testing2.sqlite3'===ev.result.filename)
|
||||
T.assert(1 && (dbFilename===ev.result.filename
|
||||
|| (sqlite3TestModule.sqlite3ApiConfig.persistentDirName
|
||||
+ dbFilename)==ev.result.filename))
|
||||
.assert(ev.dbId)
|
||||
.assert(ev.messageId)
|
||||
.assert(promiserConfig.dbId === ev.dbId);
|
||||
}).then(runTests2)
|
||||
.catch((err)=>error("error response:",err));
|
||||
}).then(runTests2);
|
||||
};
|
||||
|
||||
const runTests2 = async function(){
|
||||
|
22
manifest
22
manifest
@ -1,5 +1,5 @@
|
||||
C More\swork\son\show\sto\sconfigure\sthe\ssqlite3\sJS\sAPI\sbootstrapping\sprocess\sfrom\shigher-level\scode.\sInitial\sversion\sof\ssqlite3-worker1-promiser,\sa\sPromise-based\sproxy\sfor\sthe\sWorker\sAPI\s#1.
|
||||
D 2022-08-24T05:59:23.851
|
||||
C js:\sresolve\sthe\smysterious\s"extra"\sunhandled\sexception\snotification,\scaused\sby\sinadvertently\sforking\sone\spromise\sinto\stwo\sseparate\sones\s(failing\sto\sproperly\sreassign\sa\sthen()\sresult).\sFix\sa\stypo\sin\snew\sWorker\s1\scode\swhich\scaused\sthe\sDB(filename)\sname\sto\sbe\sincorrect.
|
||||
D 2022-08-24T14:50:10.920
|
||||
F .fossil-settings/empty-dirs dbb81e8fc0401ac46a1491ab34a7f2c7c0452f2f06b54ebb845d024ca8283ef1
|
||||
F .fossil-settings/ignore-glob 35175cdfcf539b2318cb04a9901442804be81cd677d8b889fcc9149c21f239ea
|
||||
F LICENSE.md df5091916dbb40e6e9686186587125e1b2ff51f022cc334e886c19a0e9982724
|
||||
@ -481,12 +481,12 @@ F ext/wasm/api/EXPORTED_RUNTIME_METHODS.sqlite3-api 1ec3c73e7d66e95529c3c64ac3de
|
||||
F ext/wasm/api/README.md d876597edd2b9542b6ea031adaaff1c042076fde7b670b1dc6d8a87b28a6631b
|
||||
F ext/wasm/api/post-js-footer.js b64319261d920211b8700004d08b956a6c285f3b0bba81456260a713ed04900c
|
||||
F ext/wasm/api/post-js-header.js 0e853b78db83cb1c06b01663549e0e8b4f377f12f5a2d9a4a06cb776c003880b
|
||||
F ext/wasm/api/sqlite3-api-cleanup.js 4c353bdc2452623f0c1c1e55ae1a0589db9cbaed9756760bb15179ef9b58bc98
|
||||
F ext/wasm/api/sqlite3-api-cleanup.js 1a12e64060c2cb0defd34656a76a9b1d7ed58459c290249bb31567c806fd44de
|
||||
F ext/wasm/api/sqlite3-api-glue.js 67ca83974410961953eeaa1dfed3518530d68381729ed1d27f95122f5baeabd3
|
||||
F ext/wasm/api/sqlite3-api-oo1.js f6dcaac3270182471f97efcfda25bd4a4ac1777b8ec52ebd1c6846721160e54c
|
||||
F ext/wasm/api/sqlite3-api-opfs.js 011799db398157cbd254264b6ebae00d7234b93d0e9e810345f213a5774993c0
|
||||
F ext/wasm/api/sqlite3-api-prologue.js 4a279604272851696975837534739597206c0800c8ea78810fe8e211ee101374
|
||||
F ext/wasm/api/sqlite3-api-worker1.js 9691e144a77490f482caa2c0f0bd38a8f955c6dc9c10b2f39c6491e817aefd8c
|
||||
F ext/wasm/api/sqlite3-api-prologue.js 2d5c5d3355f55eefe51922cec5bfedbec0f8300db98a17685ab7a34a03953c7a
|
||||
F ext/wasm/api/sqlite3-api-worker1.js b23f66ef5afd350a17fbadb795007098e518a40e5c7c439cd83ef34aa55a45af
|
||||
F ext/wasm/api/sqlite3-wasi.h 25356084cfe0d40458a902afb465df8c21fc4152c1d0a59b563a3fba59a068f9
|
||||
F ext/wasm/api/sqlite3-wasm.c 0d81282eaeff2a6e9fc5c28a388c5c5b45cf25a9393992fa511ac009b27df982
|
||||
F ext/wasm/common/SqliteTestUtil.js eb96275bed43fdb364b7d65bcded0ca5e22aaacff120d593d1385f852f486247
|
||||
@ -508,10 +508,10 @@ F ext/wasm/scratchpad-opfs-main.js 69e960e9161f6412fd0c30f355d4112f1894d6609eb43
|
||||
F ext/wasm/scratchpad-opfs-worker.html 66c1d15d678f3bd306373d76b61c6c8aef988f61f4a8dd40185d452f9c6d2bf5
|
||||
F ext/wasm/scratchpad-opfs-worker.js 3ec2868c669713145c76eb5877c64a1b20741f741817b87c907a154b676283a9
|
||||
F ext/wasm/scratchpad-opfs-worker2.js 5f2237427ac537b8580b1c659ff14ad2621d1694043eaaf41ae18dbfef2e48c0
|
||||
F ext/wasm/sqlite3-worker1-promiser.js 291f89330bc856e7ef8a321b4891554633c6407b52efc69c9b1d1b3e7c69d4a6
|
||||
F ext/wasm/sqlite3-worker1-promiser.js 9638b0ced7f02806c3220b616f08729dde9eb13fb56e125cd4759f40bfa81210
|
||||
F ext/wasm/sqlite3-worker1.js 0c1e7626304543969c3846573e080c082bf43bcaa47e87d416458af84f340a9e
|
||||
F ext/wasm/testing-worker1-promiser.html 6eaec6e04a56cf24cf4fa8ef49d78ce8905dde1354235c9125dca6885f7ce893 w ext/wasm/testing-worker-promise.html
|
||||
F ext/wasm/testing-worker1-promiser.js 3c13fda53cc8b5d148ae34f621eba99aff393d66718b216bfd9d3f9075dd83bc w ext/wasm/testing-worker-promise.js
|
||||
F ext/wasm/testing-worker1-promiser.html 6eaec6e04a56cf24cf4fa8ef49d78ce8905dde1354235c9125dca6885f7ce893
|
||||
F ext/wasm/testing-worker1-promiser.js 931d909c769c57292f1cafdf10c7dab402d17cd16a6d0ec32089f67b559b058f
|
||||
F ext/wasm/testing1.html 528001c7e32ee567abc195aa071fd9820cc3c8ffc9c8a39a75e680db05f0c409
|
||||
F ext/wasm/testing1.js 2def7a86c52ff28b145cb86188d5c7a49d5993f9b78c50d140e1c31551220955
|
||||
F ext/wasm/testing2.html a66951c38137ff1d687df79466351f3c734fa9c6d9cce71d3cf97c291b2167e3
|
||||
@ -2009,8 +2009,8 @@ F vsixtest/vsixtest.tcl 6a9a6ab600c25a91a7acc6293828957a386a8a93
|
||||
F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc
|
||||
F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e
|
||||
F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0
|
||||
P 1e447849fb65887e806e3348a8a68f70ea6802bc0a1e56c385a279f27cc0cdda
|
||||
R 20d6ad983c84af7c7f2e33fe283b134d
|
||||
P b030f321bd5a38cdd5d6f6735f201afa62d30d2b0ba02e67f055b4895553a878
|
||||
R a11ec2b23afafa9cff8838dfde907f0c
|
||||
U stephan
|
||||
Z 996279c2387a16066b296229c9c99a7d
|
||||
Z 64f88270da37ddd3ce54e6e07b8ab1af
|
||||
# Remove this line to create a well-formed Fossil manifest.
|
||||
|
@ -1 +1 @@
|
||||
b030f321bd5a38cdd5d6f6735f201afa62d30d2b0ba02e67f055b4895553a878
|
||||
7467ac88801224089b51c6ba7924f93283dd87beca602a186c83632df26cfc85
|
Reference in New Issue
Block a user