fix: preserve the raw flag of logs queued during a pause - #447
Conversation
`_wrapLogFn` stores `isRaw` as the fourth entry of the queue item, but `resumeLogs` only forwarded the first three, so `_logFn` always received `isRaw === undefined` when replaying. A `.raw()` call made while paused therefore took the non-raw branch on resume: a single log-object argument was merged into the log object instead of being passed through as an argument, producing different output than the same call made without a pause. Forward `item[3]` and cover both paths with tests. Fixes unjs#438
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Pro Plus Run ID: 📒 Files selected for processing (2)
Included review availability: Your plan provides up to 8 included reviews per hour; 7 remain after this review. 📝 WalkthroughWalkthrough
ChangesQueued log replay
Estimated code review effort: 2 (Simple) | ~10 minutes Merge Risk: ⚪ Minimal · up to This localized change preserves raw log arguments during pause/resume replay and adds regression tests for both raw and non-raw behavior; no actionable merge-blocking risk remains after normal checks and review. 🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
Fixes #438.
Problem
_wrapLogFnstoresisRawas the fourth entry of the queue item:but
resumeLogsonly forwarded the first three:so
_logFnalways receivedisRaw === undefinedwhen replaying a queued log. That falsy value activates the log-object branch:A
.raw()call made while paused therefore behaves differently from the same call made without a pause: a single log-object argument is merged into the log object instead of being passed through as an argument.Fix
Forward
item[3]inresumeLogs.Tests
test/consola.test.tshad no coverage forpauseLogs/resumeLogsat all, so this adds two tests:resumeLogs preserves the raw flag of queued logs— logs the same raw object once without a pause and once through a pause/resume cycle, and asserts both reporter calls receive identicalargs. It fails onmainand passes with the fix.resumeLogs still merges non-raw log objects of queued logs— pins the non-raw queued path so the fix does not accidentally make every replayed log raw.Validation
npx vitest run-> 5 passed (5)pnpm lint(eslint .+prettier -c src examples test) -> cleanSummary by CodeRabbit
Bug Fixes
Tests