diff --git a/packages/vitest/src/runtime/detect-async-leaks.ts b/packages/vitest/src/runtime/detect-async-leaks.ts index c0bdc4bd3..c291edabb 100644 --- a/packages/vitest/src/runtime/detect-async-leaks.ts +++ b/packages/vitest/src/runtime/detect-async-leaks.ts @@ -47,6 +47,11 @@ export function detectAsyncLeaks( Error.stackTraceLimit = limit } + // a builtin loaded on first use can create pending promises at the module level + if (stack.includes('node:internal/bootstrap/realm')) { + return + } + if (!stack.includes(testFile)) { const trigger = resources.get(triggerAsyncId)