-
Notifications
You must be signed in to change notification settings - Fork 98
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add conditional checks for window
object
#839
Conversation
WalkthroughThe recent changes ensure that Changes
Sequence Diagram(s) (Beta)sequenceDiagram
participant Browser
participant Window
participant DevTools
Browser->>DevTools: Initialize transactionEventsByDocKey
DevTools->>Window: Attach transactionEventsByDocKey to Window
Window-->>DevTools: transactionEventsByDocKey is now globally accessible
Poem
Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media? TipsChatThere are 3 ways to chat with CodeRabbit:
Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments. CodeRabbit Commands (invoked as PR comments)
Additionally, you can add CodeRabbit Configration File (
|
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #839 +/- ##
==========================================
- Coverage 80.68% 80.66% -0.02%
==========================================
Files 59 59
Lines 4576 4577 +1
Branches 930 931 +1
==========================================
Hits 3692 3692
Misses 616 616
- Partials 268 269 +1 ☔ View full report in Codecov by Sentry. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 0
Outside diff range and nitpick comments (3)
src/devtools/index.ts (3)
Line range hint
100-100
: Replace non-null assertion with optional chaining.Unsafe use of non-null assertion can lead to runtime errors. Replace with optional chaining to ensure safety.
- transactionEventsByDocKey.get(doc.getKey())!.push(event); + transactionEventsByDocKey.get(doc.getKey())?.push(event);
Line range hint
100-100
: Address TODO for unsubscribing from document events.The TODO comment suggests a need to handle unsubscribing from document events. This is crucial for preventing memory leaks. Would you like assistance in implementing this feature?
Line range hint
151-151
: Ensure removal of event listeners.The TODO comment indicates the need to remove event listeners to prevent potential memory leaks or unintended behavior. It's important to address this. Would you like help with this implementation?
Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Files selected for processing (1)
- src/devtools/index.ts (1 hunks)
Additional context used
Biome
src/devtools/index.ts
[error] 100-100: Forbidden non-null assertion.
Unsafe fix: Replace with optional chain operator ?. This operator includes runtime checks, so it is safer than the compile-only non-null assertion operator
[error] 151-151: Forbidden non-null assertion.
Additional comments not posted (2)
src/devtools/index.ts (2)
37-44
: Ensurewindow
object is only accessed when defined.The changes correctly implement a check for the
window
object before accessing it, which should prevent thewindow is not defined
error in server-side environments. Good use of TypeScript's global declaration to extend theWindow
interface.
Line range hint
151-151
: Replace non-null assertion with optional chaining.Refer to the previous comment regarding the replacement of non-null assertions with optional chaining.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for your contribution.
What this PR does / why we need it?
This pull request addresses the issue of the
window is not defined
error encountered in the Next.js example.Any background context you want to provide?
What are the relevant tickets?
Fixes #
Checklist
Summary by CodeRabbit
transactionEventsByDocKey
available as a global property.