| 409 | } |
| 410 | |
| 411 | function leakedGlobals() { |
| 412 | const leaked = []; |
| 413 | |
| 414 | for (const val in globalThis) { |
| 415 | // globalThis.crypto is a getter that throws if Node.js was compiled |
| 416 | // without OpenSSL so we'll skip it if it is not available. |
| 417 | if (val === 'crypto' && !hasCrypto) { |
| 418 | continue; |
| 419 | } |
| 420 | // globalThis.localStorage is a getter that throws if Node.js was |
| 421 | // executed without a --localstorage-file path. |
| 422 | if (val === 'localStorage' && !hasLocalStorage) { |
| 423 | continue; |
| 424 | } |
| 425 | if (!knownGlobals.has(globalThis[val])) { |
| 426 | leaked.push(val); |
| 427 | } |
| 428 | } |
| 429 | |
| 430 | return leaked; |
| 431 | } |
| 432 | |
| 433 | process.on('exit', function() { |
| 434 | const leaked = leakedGlobals(); |