From 56ea47a9aba39998659461f196879607f439aea8 Mon Sep 17 00:00:00 2001 From: Dmitry Vasilev Date: Wed, 8 Feb 2023 05:32:32 +0800 Subject: [PATCH] fixes --- src/record_io.js | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/src/record_io.js b/src/record_io.js index 2784867..782a18f 100644 --- a/src/record_io.js +++ b/src/record_io.js @@ -73,8 +73,9 @@ const io_patch = (cxt, path, use_context = false) => { console.log('value', value) if(value instanceof cxt.window.Promise) { - // TODO use native .finally for promise, not patched then? - value.finally(() => { + // TODO use cxt.promise_then, not finally which calls + // patched 'then'? + value = value.finally(() => { // TODO guard calls from prev runs // TODO guard io_cache_is_replay_aborted cxt.io_cache.push({type: 'resolution', index}) @@ -200,7 +201,8 @@ const io_patch = (cxt, path, use_context = false) => { if(call.ok) { if(call.value instanceof cxt.window.Promise) { - return new Promise(resolve => { + // Always make promise originate from run_window + return new cxt.window.Promise(resolve => { cxt.io_cache_resolvers.set(cxt.io_cache_index - 1, resolve) }) } else if(name == 'setTimeout') {