Fix bug: debugger can get invoked at the top level in some contexts