File tree Expand file tree Collapse file tree 2 files changed +8
-1
lines changed
tools/server/public_simplechat Expand file tree Collapse file tree 2 files changed +8
-1
lines changed Original file line number Diff line number Diff line change @@ -15,6 +15,7 @@ import * as xpromise from "./xpromise.mjs"
1515
1616
1717self . onmessage = async function ( ev ) {
18+ console . info ( "DBUG:WW:OnMessage started..." )
1819 tconsole . console_redir ( )
1920 try {
2021 await xpromise . evalWithPromiseTracking ( ev . data . code ) ;
@@ -23,4 +24,5 @@ self.onmessage = async function (ev) {
2324 }
2425 tconsole . console_revert ( )
2526 self . postMessage ( { id : ev . data . id , name : ev . data . name , data : tconsole . gConsoleStr } )
27+ console . info ( "DBUG:WW:OnMessage done" )
2628}
Original file line number Diff line number Diff line change 1313 * Eval which allows promises generated by the evald code to be tracked.
1414 * @param {string } codeToEval
1515 */
16- export function evalWithPromiseTracking ( codeToEval ) {
16+ export async function evalWithPromiseTracking ( codeToEval ) {
1717 const _Promise = globalThis . Promise ;
1818 /** @type {any[] } */
1919 const trackedPromises = [ ] ;
2020
2121 const Promise = function ( /** @type {PromiseExecutor } */ executor ) {
22+ console . info ( "WW:PT:Promise" )
2223 const promise = new _Promise ( executor ) ;
2324 trackedPromises . push ( promise ) ;
2425
2526 promise . then = function ( ...args ) {
27+ console . info ( "WW:PT:Then" )
2628 const newPromise = _Promise . prototype . then . apply ( this , args ) ;
2729 trackedPromises . push ( newPromise ) ;
2830 return newPromise ;
2931 } ;
3032
3133 promise . catch = function ( ...args ) {
34+ console . info ( "WW:PT:Catch" )
3235 const newPromise = _Promise . prototype . catch . apply ( this , args ) ;
3336 trackedPromises . push ( newPromise ) ;
3437 return newPromise ;
@@ -42,5 +45,7 @@ export function evalWithPromiseTracking(codeToEval) {
4245
4346 eval ( codeToEval ) ;
4447
48+ //await Promise(resolve=>setTimeout(resolve, 0));
49+ //return _Promise.allSettled(trackedPromises);
4550 return _Promise . all ( trackedPromises ) ;
4651}
You can’t perform that action at this time.
0 commit comments