Fix createConsoleSink() ignoring falsy timestamps like 0#705
Conversation
Summary of ChangesHello, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed! This pull request resolves a bug in Highlights
Using Gemini Code AssistThe full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips. Invoking Gemini You can request assistance from Gemini at any point by creating a comment using either
Customization To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a Limitations & Feedback Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for GitHub and other Google products, sign up here. Footnotes
|
There was a problem hiding this comment.
Code Review
This pull request correctly fixes a bug where a timestamp of 0 was being ignored by createConsoleSink(). The change from a truthiness check to a nullish check is appropriate. The addition of a regression test and strengthening of an existing test are also great improvements. I've suggested a small refinement to make the code more concise and align with the repository's style guide regarding default values.
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Repository UI Review profile: ASSERTIVE Plan: Pro Run ID: 📒 Files selected for processing (2)
WalkthroughThe PR fixes timestamp handling in createConsoleSink() so only null/undefined/NaN cause falling back to the current time; falsy numeric timestamps like 0 are now formatted as the Unix epoch. Tests were added: one asserting Estimated code review effort🎯 2 (Simple) | ⏱️ ~10 minutes 🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches📝 Generate docstrings
🧪 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 |
The truthiness check `record.timestamp ? ...` treated a valid timestamp of `0` (Unix epoch) as absent because `0` is falsy in JavaScript. Use a nullish check (`!= null`) instead. Close #311 Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
1d29a0f to
f638e97
Compare
#705 (comment) Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
|
@codex review |
|
/gemini review |
There was a problem hiding this comment.
Code Review
This pull request correctly fixes a bug where a timestamp of 0 was being ignored by createConsoleSink(). The change from a truthiness check to a nullish coalescing operator is the right approach and aligns with the project's style guide. The addition of a specific regression test for this case and the strengthening of an existing test are excellent practices that improve the robustness of the codebase. The changes are well-implemented and I have no further suggestions.
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: f1e4357bd6
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
When record.timestamp is NaN, new Date(NaN).toISOString() throws a RangeError. Add a Number.isNaN() check to fall back to the current time instead of crashing. #705 (comment) Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
|
@codex review |
|
/gemini review |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: d02189e0c1
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
There was a problem hiding this comment.
Code Review
This pull request correctly fixes an issue where a timestamp of 0 was ignored in createConsoleSink(). The change from a truthiness check to a nullish and isNaN check is robust and also handles the NaN edge case. The added tests effectively cover the fix and the edge case. The suggestion to refactor the new tests to reduce code duplication by extracting a helper function is not necessary, as the duplication is minimal and a local helper is preferred.
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #705 +/- ##
=======================================
Coverage ? 93.96%
=======================================
Files ? 38
Lines ? 19135
Branches ? 5217
=======================================
Hits ? 17980
Misses ? 1135
Partials ? 20 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
createConsoleSink()used a truthiness check onrecord.timestampto decide whether to format the record's timestamp or fall back to the current time:Because
0is falsy in JavaScript, a valid timestamp of0(the Unix epoch,1970-01-01T00:00:00.000Z) was silently replaced withnew Date(), producing the current wall-clock time instead.The fix replaces the truthiness check with a nullish check (
record.timestamp != null), so that0and any other falsy-but-valid numeric timestamps are preserved correctly.A regression test for
timestamp: 0has been added, and the existing "should route by stream resolver" test in index.test.ts has been strengthened to also verify the timestamp value in its output.Closes #311