collect logs from failed call

This commit is contained in:
Dmitry Vasilev
2022-11-15 16:01:13 +08:00
parent e24e88625c
commit 97e952f2d3
2 changed files with 7 additions and 11 deletions

View File

@@ -272,7 +272,6 @@ export const eval_modules = (
let call_counter = 0 let call_counter = 0
let is_entrypoint
let searched_location let searched_location
let found_call let found_call
@@ -330,8 +329,6 @@ export const eval_modules = (
stack.push(false) stack.push(false)
const is_found_call = const is_found_call =
is_entrypoint
&&
(searched_location != null && found_call == null) (searched_location != null && found_call == null)
&& &&
( (
@@ -425,9 +422,8 @@ export const eval_modules = (
children = null children = null
stack.push(false) stack.push(false)
const is_log = is_entrypoint // TODO: other console fns
? fn == console.log || fn == console.error // TODO: other console fns const is_log = fn == console.log || fn == console.error
: undefined
if(is_log) { if(is_log) {
set_record_call() set_record_call()
@@ -495,8 +491,8 @@ export const eval_modules = (
sorted sorted
.map((m, i) => .map((m, i) =>
` `
is_entrypoint = entrypoint == '${m}'
__modules['${m}'] = {} __modules['${m}'] = {}
found_call = null
children = null children = null
current_call = { current_call = {
toplevel: true, toplevel: true,
@@ -540,14 +536,10 @@ export const eval_modules = (
` `
const actions = make_function( const actions = make_function(
'entrypoint',
'external_imports', 'external_imports',
'on_async_call', 'on_async_call',
codestring codestring
)( )(
/* entrypoint */
sorted[sorted.length - 1],
/* external_imports */ /* external_imports */
external_imports == null external_imports == null
? null ? null

View File

@@ -2259,11 +2259,15 @@ const y = x()`
'x' : ` 'x' : `
const has_child_calls = i => i == 0 ? 0 : has_child_calls(i - 1) const has_child_calls = i => i == 0 ? 0 : has_child_calls(i - 1)
has_child_calls(10) has_child_calls(10)
console.log('log')
throw new Error('fail') throw new Error('fail')
`, `,
}) })
assert_equal(root_calltree_node(s).module, 'x') assert_equal(root_calltree_node(s).module, 'x')
// Must collect logs from failed module
assert_equal(s.logs.logs.length, 1)
const s2 = COMMANDS.move_cursor( const s2 = COMMANDS.move_cursor(
COMMANDS.change_current_module(s, 'x'), COMMANDS.change_current_module(s, 'x'),
s.files['x'].indexOf('throw') s.files['x'].indexOf('throw')