diff --git a/src/runtime/record_io.js b/src/runtime/record_io.js index efb4d4a..334e473 100644 --- a/src/runtime/record_io.js +++ b/src/runtime/record_io.js @@ -31,6 +31,12 @@ const make_patched_method = (window, original, name, use_context) => { throw error } + // save call, so on expand_call and find_call IO functions would not be + // called. + // TODO: we have a problem when IO function is called from third-party + // lib and async context is lost + set_record_call(cxt) + const has_new_target = new.target != null if(cxt.is_recording_deferred_calls) { @@ -45,12 +51,6 @@ const make_patched_method = (window, original, name, use_context) => { if(cxt.io_trace_is_recording) { let ok, value, error try { - // save call, so on expand_call and find_call IO functions would not be - // called. - // TODO: we have a problem when IO function is called from third-party - // lib and async context is lost - set_record_call(cxt) - const index = cxt.io_trace.length if(name == 'setTimeout') { diff --git a/test/test.js b/test/test.js index b210cb2..ac96c59 100644 --- a/test/test.js +++ b/test/test.js @@ -4200,6 +4200,24 @@ const y = x()` assert_equal(second.state.logs.logs.length, 1) }), + test('record io expand_calltree_node bug', () => { + const code = ` + function x(i) { + return i == 0 ? Math.random() : x(i - 1) + } + x(2) + x(2) + ` + const i = test_initial_state(code) + const with_trace = run_code(i) + const second_call = root_calltree_node(with_trace).children[1] + assert_equal(second_call.fn.name, 'x') + const expanded = COMMANDS.calltree.select_and_toggle_expanded(with_trace, second_call.id) + const second_call_2 = root_calltree_node(expanded).children[1] + assert_equal(second_call_2.ok, true) + assert_equal(second_call.value, second_call_2.value) + }), + test('value_explorer Set', () => { assert_equal( header(new Set(['foo', 'bar'])),