-
Notifications
You must be signed in to change notification settings - Fork 5.5k
[Notion] reset state after restart #14241
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
[Notion] reset state after restart #14241
Conversation
The latest updates on your projects. Learn more about Vercel for Git ↗︎ |
WalkthroughThe pull request includes updates to the Changes
Possibly related PRs
Suggested reviewers
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 using PR comments)
Other keywords and placeholders
CodeRabbit Configuration File (
|
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: 1
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
📒 Files selected for processing (2)
- components/notion/package.json (1 hunks)
- components/notion/sources/updated-page/updated-page.mjs (9 hunks)
✅ Files skipped from review due to trivial changes (1)
- components/notion/package.json
🧰 Additional context used
🔇 Additional comments (7)
components/notion/sources/updated-page/updated-page.mjs (7)
12-12
: Version update approvedThe version increment from "0.1.2" to "0.1.3" appropriately reflects the changes made in this component.
Line range hint
155-157
: Validate the break condition in pages processing loopThe condition
if (lastCheckedTimestamp > Date.parse(page.last_edited_time)) { break; }
breaks out of the loop when a page's last edited time is earlier than the last checked timestamp. Ensure that the pages are sorted in ascending order oflast_edited_time
to prevent skipping updated pages. If the sorting is not guaranteed, consider usingcontinue
instead ofbreak
.
85-91
: Method renaming to indicate internal useRenaming methods to include a leading underscore (e.g.,
_getPropertiesToCheck
,_generateMeta
,_emitEvent
) appropriately signals that they are intended for internal use. Ensure all references to these methods are updated to prevent anyundefined
method errors.Also applies to: 106-115, 116-124
43-60
:⚠️ Potential issueVerify potential event loss during activation
In the
activate
hook, setting the last updated timestamp to the current time withthis._setLastUpdatedTimestamp(Date.now());
may result in missing events that occurred just before activation. Please verify that this behavior doesn't unintentionally skip any relevant events during the activation process.
61-63
:⚠️ Potential issueEnsure proper state handling during deactivation
Clearing the last updated timestamp in the
deactivate
hook withthis._setLastUpdatedTimestamp(null);
might affect the event emission when the source is reactivated. Confirm that this won't lead to any issues in tracking updates after reactivation.
68-73
:⚠️ Potential issueCheck compatibility of 'structuredClone'
The
structuredClone
function is used in methods_maybeRemoveFileSubItems
and within therun
method at line 165. SincestructuredClone
is available in Node.js 17+, please ensure that the runtime environment supports it. If not, consider using alternative deep cloning methods likeJSON.parse(JSON.stringify(obj))
or a utility library.Also applies to: 92-99, 165-165
131-135
:⚠️ Potential issueConfirm skipping execution logic when last updated timestamp is null
In the
run
method, whenlastCheckedTimestamp
is null, the execution is skipped. Verify that this logic doesn't prevent the processing of pending events, especially after deactivation and immediate reactivation.
const lastCheckedTimestamp = this._getLastUpdatedTimestamp(); | ||
const propertyValues = this._getPropertyValues(); | ||
|
||
if (!lastCheckedTimestamp) { | ||
// recently updated (deactivated / activated), skip execution | ||
console.log("Awaiting restart completion: skipping execution"); | ||
return; | ||
} | ||
|
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.
🛠️ Refactor suggestion
Handle potential missed events during state transitions
The logic that skips execution when lastCheckedTimestamp
is not set might result in missed events during activation or deactivation. Consider processing any pending events to ensure no updates are lost during these transitions.
WHY
Summary by CodeRabbit
New Features
notion-updated-page
component to include new activation and deactivation hooks for improved lifecycle management.Version Updates
@pipedream/notion
package andnotion-updated-page
component.Improvements