Skip to content

Commit 5763085

Browse files
committed
fix(suppress-warnings): properly restore state in withSuppressedWarnings
Track whether warning type was already suppressed before modification. Only remove from suppressedWarnings set if this function added it. Ensures proper cleanup and restoration of original process.emitWarning state.
1 parent c7f84fc commit 5763085

File tree

1 file changed

+5
-0
lines changed

1 file changed

+5
-0
lines changed

src/suppress-warnings.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -144,11 +144,16 @@ export async function withSuppressedWarnings<T>(
144144
warningType: string,
145145
callback: () => T | Promise<T>,
146146
): Promise<T> {
147+
const wasAlreadySuppressed = suppressedWarnings.has(warningType)
147148
const original = process.emitWarning
148149
suppressWarningType(warningType)
149150
try {
150151
return await callback()
151152
} finally {
153+
// Only remove from suppressed set if we added it.
154+
if (!wasAlreadySuppressed) {
155+
suppressedWarnings.delete(warningType)
156+
}
152157
process.emitWarning = original
153158
}
154159
}

0 commit comments

Comments
 (0)