-
-
Notifications
You must be signed in to change notification settings - Fork 638
Remove gap in page lifecycle check for setup listeners #1771
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
Conversation
We currently have a gap between the DOMContentLoaded event & readystate === 'complete' (which is after the load event), where this script could run and NOTHING happen.
WalkthroughAdjusted initializePageEventListeners to treat any document.readyState other than 'loading' as ready, invoking setupPageNavigationListeners immediately in 'interactive' or 'complete'. Retained DOMContentLoaded listener only for the 'loading' state. No public API changes. Changes
Sequence Diagram(s)sequenceDiagram
autonumber
participant B as Browser
participant L as pageLifecycle
participant N as setupPageNavigationListeners
B->>L: initializePageEventListeners()
alt document.readyState !== 'loading' (interactive/complete)
Note over L: New behavior triggers immediately for 'interactive' too
L->>N: setup()
else document.readyState === 'loading'
L-->>B: addEventListener('DOMContentLoaded', ...)
B-->>L: DOMContentLoaded
L->>N: setup()
end
Estimated code review effort🎯 2 (Simple) | ⏱️ ~10 minutes Pre-merge checks (2 passed, 1 warning)❌ Failed checks (1 warning)
✅ Passed checks (2 passed)
Poem
Tip 👮 Agentic pre-merge checks are now available in preview!Pro plan users can now enable pre-merge checks in their settings to enforce checklists before merging PRs.
Example: reviews:
pre_merge_checks:
custom_checks:
- name: "Undocumented Breaking Changes"
mode: "warning"
instructions: |
Pass/fail criteria: All breaking changes to public APIs, CLI flags, environment variables, configuration keys, database schemas, or HTTP/GraphQL endpoints must be documented in the "Breaking Change" section of the PR description and in CHANGELOG.md. Exclude purely internal or private changes (e.g., code not exported from package entry points or explicitly marked as internal).Please share your feedback with us on this Discord post. ✨ Finishing Touches
🧪 Generate unit tests
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 |
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
🧹 Nitpick comments (1)
node_package/src/pageLifecycle.ts (1)
70-74: Use a one-shot DOMContentLoaded listener to avoid a lingering handler.Make the fallback listener self-removing.
} else { - document.addEventListener('DOMContentLoaded', setupPageNavigationListeners); + document.addEventListener('DOMContentLoaded', setupPageNavigationListeners, { once: true }); }
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (1)
node_package/src/pageLifecycle.ts(1 hunks)
🧰 Additional context used
📓 Path-based instructions (2)
node_package/src/**/*.{ts,tsx,js,jsx}
📄 CodeRabbit inference engine (CLAUDE.md)
JavaScript/TypeScript code must adhere to ESLint rules (project uses ESLint for JS/TS linting)
Files:
node_package/src/pageLifecycle.ts
node_package/src/**/*.{ts,tsx}
📄 CodeRabbit inference engine (CLAUDE.md)
Client-side source should be authored in TypeScript under node_package/src (compiled to node_package/lib)
Files:
node_package/src/pageLifecycle.ts
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (5)
- GitHub Check: dummy-app-integration-tests (newest)
- GitHub Check: dummy-app-integration-tests (oldest)
- GitHub Check: build
- GitHub Check: rspec-package-tests (oldest)
- GitHub Check: rspec-package-tests (newest)
🔇 Additional comments (2)
node_package/src/pageLifecycle.ts (2)
70-74: Good fix: close the 'interactive' gap.Switching to
document.readyState !== 'loading'correctly handles the window betweenDOMContentLoadedandload, so listeners are set up when the doc isinteractiveorcomplete.
70-74: Verify Turbo/Turbolinks availability before attaching listeners. Confirm our integration guarantees that Turbo/Turbolinks scripts are loaded by the timeDOMContentLoaded/interactivefires; if not, add a minimal fallback (e.g. re-check onwindow.loadwith guards to avoid duplicate installs).
|
Superseded by #1773 |
We currently have a gap between the
DOMContentLoadedevent &readystate === 'complete'(which is after theloadevent), where this script could run and NOTHING happen.This change is
Summary by CodeRabbit