(maxDepth: number)
| 31 | }); |
| 32 | |
| 33 | const onceBp = (maxDepth: number): IAsyncStackPolicy => { |
| 34 | const onEnable: EventEmitter<void> | undefined = new EventEmitter<void>(); |
| 35 | let enabled = false; |
| 36 | const tryEnable = () => { |
| 37 | if (!enabled) { |
| 38 | enabled = true; |
| 39 | onEnable.fire(); |
| 40 | } |
| 41 | }; |
| 42 | |
| 43 | return { |
| 44 | async connect(cdp) { |
| 45 | if (enabled) { |
| 46 | await cdp.Debugger.setAsyncCallStackDepth({ maxDepth }); |
| 47 | return noOpDisposable; |
| 48 | } |
| 49 | |
| 50 | const disposable = new DisposableList(); |
| 51 | |
| 52 | disposable.push( |
| 53 | // Another session enabled breakpoints. Turn this on as well, e.g. if |
| 54 | // we have a parent page and webworkers, when we debug the webworkers |
| 55 | // should also have their async stacks turned on. |
| 56 | onEnable.event(() => { |
| 57 | disposable.dispose(); |
| 58 | cdp.Debugger.setAsyncCallStackDepth({ maxDepth }); |
| 59 | }), |
| 60 | // when a breakpoint resolves, turn on stacks because we're likely to |
| 61 | // pause sooner or later |
| 62 | cdp.Debugger.on('breakpointResolved', tryEnable), |
| 63 | // start collecting on a pause event. This can be from source map |
| 64 | // instrumentation, entrypoint breakpoints, debugger statements, or user |
| 65 | // defined breakpoints. Instrumentation points happen all the time and |
| 66 | // can be ignored. For others, including entrypoint breaks (which |
| 67 | // indicate there's a user break somewhere in the file) we should turn on. |
| 68 | cdp.Debugger.on('paused', evt => { |
| 69 | if (evt.reason !== 'instrumentation') { |
| 70 | tryEnable(); |
| 71 | } |
| 72 | }), |
| 73 | ); |
| 74 | |
| 75 | return disposable; |
| 76 | }, |
| 77 | }; |
| 78 | }; |
| 79 | |
| 80 | const defaultPolicy = eager(32); |
| 81 |
no outgoing calls
no test coverage detected