()
| 547 | let getStructuredStackImpl; |
| 548 | |
| 549 | function lazyGetStructuredStack() { |
| 550 | if (getStructuredStackImpl === undefined) { |
| 551 | // Lazy-load to avoid a circular dependency. |
| 552 | const { runInNewContext } = require('vm'); |
| 553 | // Use `runInNewContext()` to get something tamper-proof and |
| 554 | // side-effect-free. Since this is currently only used for a deprecated API |
| 555 | // and module mocking, the perf implications should be okay. |
| 556 | getStructuredStackImpl = runInNewContext(`(function() { |
| 557 | try { Error.stackTraceLimit = Infinity; } catch {} |
| 558 | return function structuredStack() { |
| 559 | const e = new Error(); |
| 560 | overrideStackTrace.set(e, (err, trace) => trace); |
| 561 | return e.stack; |
| 562 | }; |
| 563 | })()`, { overrideStackTrace }, { filename: 'structured-stack' }); |
| 564 | } |
| 565 | |
| 566 | return getStructuredStackImpl; |
| 567 | } |
| 568 | |
| 569 | function getStructuredStack() { |
| 570 | const getStructuredStackImpl = lazyGetStructuredStack(); |
no test coverage detected
searching dependent graphs…