Skip to content

Commit 5d76493

Browse files
committed
SimpleChatTC:Promises: trap normal fetch (dont care await or not)
1 parent 7dc999f commit 5d76493

File tree

1 file changed

+9
-0
lines changed

1 file changed

+9
-0
lines changed

tools/server/public_simplechat/xpromise.mjs

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,8 @@
1515
*/
1616
export async function evalWithPromiseTracking(codeToEval) {
1717
const _Promise = globalThis.Promise;
18+
const _fetch = globalThis.fetch
19+
1820
/** @type {any[]} */
1921
const trackedPromises = [];
2022

@@ -43,6 +45,13 @@ export async function evalWithPromiseTracking(codeToEval) {
4345
Promise.prototype = _Promise.prototype;
4446
Object.assign(Promise, _Promise);
4547

48+
const fetch = function(/** @type {any[]} */ ...args) {
49+
console.info("WW:PT:Fetch")
50+
const fpromise = _fetch(args);
51+
trackedPromises.push(fpromise)
52+
return fpromise;
53+
}
54+
4655
eval(codeToEval);
4756

4857
//await Promise(resolve=>setTimeout(resolve, 0));

0 commit comments

Comments
 (0)