n8n - ✅(Solved) Fix bug(nodes-base): NotionTrigger stores moment.js object in staticData, causing WorkflowActivationError on every activation [1 pull requests, 1 comments, 2 participants]

Official PRs (…)
ON THIS PAGE

Recommended Tools

×6

Utilities matched from this issue’s tags and category — try them while you read without losing context.

GitHub issue graph ai analysis

Paste a GitHub issue URL. We fetch that issue, discover linked issues from bodies/comments/timeline, collect linked pull requests, and produce a structured English report.

The report is written in English Markdown for sharing and archival.

Helpful · Quick feedback

Loading…
GitHub stats
n8n-io/n8n#28445Fetched 2026-04-15 06:44:31
View on GitHub
Comments
1
Participants
2
Timeline
8
Reactions
0
Timeline (top)
labeled ×3commented ×1cross-referenced ×1mentioned ×1

Error Message

WorkflowActivationError: There was a problem activating the workflow: "this is not a Date object." at ActiveWorkflows.add (.../n8n-core/.../active-workflows.ts:130:11) at ActiveWorkflowManager.addTriggersAndPollers (...) at ActiveWorkflowManager.add (...)

Root Cause

In NotionTrigger.node.ts, poll() stores a moment.js object (not a native Date, not an ISO string) into webhookData.lastTimeChecked:

// packages/nodes-base/nodes/Notion/NotionTrigger.node.ts
webhookData.lastTimeChecked = moment().set({ second: 0, millisecond: 0 });
//                                     ↑ moment object, NOT a Date or string

webhookData is the workflow's staticData wrapped in an observable proxy. Any assignment to it immediately queues a save to the database. When TypeORM serializes the dirty staticData, it calls native Date.prototype methods on the stored value. A moment.js object is not a Date instance, so the native prototype throws:

TypeError: this is not a Date object.

This error propagates through runPoll()executeTrigger(true)activatePolling()ActiveWorkflows.add(), where it is caught and re-wrapped as a WorkflowActivationError.

Note: once the value is persisted to the database and read back, it becomes an ISO string (moment objects serialize to ISO via .toJSON()). So the bug only fires on the first poll of a fresh activation — exactly when n8n calls executeTrigger(true) to test the trigger on activation.

Fix Action

Fix

One-line fix in NotionTrigger.node.ts:

- webhookData.lastTimeChecked = moment().set({ second: 0, millisecond: 0 });
+ webhookData.lastTimeChecked = moment().set({ second: 0, millisecond: 0 }).toISOString();

.toISOString() stores a plain string. The read-back path already handles strings correctly:

const lastTimeChecked = webhookData.lastTimeChecked
    ? moment(webhookData.lastTimeChecked)   // ← wraps string fine
    : moment().set({ second: 0, millisecond: 0 });

PR fix notes

PR #28456: fix(Notion Node): Store lastTimeChecked as ISO string instead of moment object

Description (problem / solution / changelog)

Summary

The NotionTrigger node's poll() method stores a raw moment.js object into webhookData.lastTimeChecked:

webhookData.lastTimeChecked = moment().set({ second: 0, millisecond: 0 });

webhookData is backed by the workflow's staticData, which TypeORM serializes on every mutation. During serialization, TypeORM calls native Date.prototype methods on the stored value. Since a moment.js object is not a native Date instance, this throws:

TypeError: this is not a Date object.

This error propagates up through runPoll()executeTrigger(true)ActiveWorkflows.add(), where it gets wrapped as a WorkflowActivationError — preventing any workflow with a Notion Trigger from activating.

The fix appends .toISOString() so that a plain string is stored instead. The read-back path already wraps the value with moment(), which parses ISO strings without issue, so no changes are needed there.

Related Linear tickets, Github issues, and Community forum posts

Fixes https://github.com/n8n-io/n8n/issues/28445 https://linear.app/n8n/issue/GHC-7725

Review / Merge checklist

  • I have seen this code, I have run this code, and I take responsibility for this code.
  • PR title and summary are descriptive. (conventions)
  • Docs updated or follow-up ticket created.
  • Tests included.
  • PR Labeled with Backport to Beta, Backport to Stable, or Backport to v1 (if the PR is an urgent fix that needs to be backported)

Changed files

  • packages/nodes-base/nodes/Notion/NotionTrigger.node.ts (modified, +1/-1)
  • packages/nodes-base/nodes/Notion/test/NotionTrigger.node.test.ts (added, +75/-0)

Code Example

WorkflowActivationError: There was a problem activating the workflow: "this is not a Date object."
    at ActiveWorkflows.add (.../n8n-core/.../active-workflows.ts:130:11)
    at ActiveWorkflowManager.addTriggersAndPollers (...)
    at ActiveWorkflowManager.add (...)

---

// packages/nodes-base/nodes/Notion/NotionTrigger.node.ts
webhookData.lastTimeChecked = moment().set({ second: 0, millisecond: 0 });
//                                     ↑ moment object, NOT a Date or string

---

TypeError: this is not a Date object.

---

- webhookData.lastTimeChecked = moment().set({ second: 0, millisecond: 0 });
+ webhookData.lastTimeChecked = moment().set({ second: 0, millisecond: 0 }).toISOString();

---

const lastTimeChecked = webhookData.lastTimeChecked
    ? moment(webhookData.lastTimeChecked)   // ← wraps string fine
    : moment().set({ second: 0, millisecond: 0 });
RAW_BUFFERClick to expand / collapse

Bug Description

Activating any workflow with a Notion Trigger node fails immediately with a WorkflowActivationError. The workflow retries with exponential backoff (4s → 8s → 16s → 32s → 64s) then gives up and deregisters all crons. The trigger never activates.

Error in logs:

WorkflowActivationError: There was a problem activating the workflow: "this is not a Date object."
    at ActiveWorkflows.add (.../n8n-core/.../active-workflows.ts:130:11)
    at ActiveWorkflowManager.addTriggersAndPollers (...)
    at ActiveWorkflowManager.add (...)

Root Cause

In NotionTrigger.node.ts, poll() stores a moment.js object (not a native Date, not an ISO string) into webhookData.lastTimeChecked:

// packages/nodes-base/nodes/Notion/NotionTrigger.node.ts
webhookData.lastTimeChecked = moment().set({ second: 0, millisecond: 0 });
//                                     ↑ moment object, NOT a Date or string

webhookData is the workflow's staticData wrapped in an observable proxy. Any assignment to it immediately queues a save to the database. When TypeORM serializes the dirty staticData, it calls native Date.prototype methods on the stored value. A moment.js object is not a Date instance, so the native prototype throws:

TypeError: this is not a Date object.

This error propagates through runPoll()executeTrigger(true)activatePolling()ActiveWorkflows.add(), where it is caught and re-wrapped as a WorkflowActivationError.

Note: once the value is persisted to the database and read back, it becomes an ISO string (moment objects serialize to ISO via .toJSON()). So the bug only fires on the first poll of a fresh activation — exactly when n8n calls executeTrigger(true) to test the trigger on activation.

Fix

One-line fix in NotionTrigger.node.ts:

- webhookData.lastTimeChecked = moment().set({ second: 0, millisecond: 0 });
+ webhookData.lastTimeChecked = moment().set({ second: 0, millisecond: 0 }).toISOString();

.toISOString() stores a plain string. The read-back path already handles strings correctly:

const lastTimeChecked = webhookData.lastTimeChecked
    ? moment(webhookData.lastTimeChecked)   // ← wraps string fine
    : moment().set({ second: 0, millisecond: 0 });

To Reproduce

  1. Create a workflow with a Notion Trigger node (either pageAddedToDatabase or pagedUpdatedInDatabase)
  2. Configure a valid Notion database ID with a connected integration
  3. Activate the workflow
  4. Observe WorkflowActivationError: "this is not a Date object." in logs, repeated with exponential backoff until the workflow gives up

Running the trigger node manually in the editor works fine — the bug only fires during workflow activation (the executeTrigger(true) test call).

Expected Behavior

Workflow activates cleanly and the Notion Trigger begins polling every minute.

Environment

  • n8n version: 2.16.0 (Docker image docker.n8n.io/n8nio/n8n:stable)
  • n8n-nodes-base version: 2.16.0
  • Database: SQLite
  • Execution mode: main (default)
  • OS: macOS (Docker container)

Additional Context

The same bug likely affects both pageAddedToDatabase and pagedUpdatedInDatabase event types since both code paths share the same webhookData.lastTimeChecked assignment.

extent analysis

TL;DR

The most likely fix is to modify the NotionTrigger.node.ts file to store a plain string instead of a moment.js object in webhookData.lastTimeChecked by calling toISOString().

Guidance

  • The error occurs because webhookData.lastTimeChecked is assigned a moment.js object, which is not a native Date object, causing a TypeError when TypeORM serializes the data.
  • To fix this, update the line in NotionTrigger.node.ts to store a plain string by calling toISOString() on the moment.js object.
  • Verify the fix by activating a workflow with a Notion Trigger node and checking the logs for the absence of the WorkflowActivationError.
  • If the issue persists, check the database to ensure that the webhookData.lastTimeChecked value is being stored as a string.

Example

webhookData.lastTimeChecked = moment().set({ second: 0, millisecond: 0 }).toISOString();

Notes

  • This fix assumes that the moment.js library is being used correctly and that the toISOString() method is available.
  • The bug only occurs on the first poll of a fresh activation, so it may not be immediately apparent.

Recommendation

Apply the workaround by modifying the NotionTrigger.node.ts file to store a plain string in webhookData.lastTimeChecked. This fix should resolve the WorkflowActivationError and allow the workflow to activate cleanly.

Vote matrix · Quick signals

Works
Did the solution work? Tap to confirm.
Easy Fix
Was it a quick fix?
Time Saver
Did it save you time?
Blocking
Was it severely blocking?
Common Issue
Are others likely hitting this too?
Flaky / Intermittent
Is it intermittent?
Verified / Reproducible
Can you reproduce it reliably?
Loading…

Still need to ship something?

×6

Another batch ranked right after the header list — different links, same matching logic.

Back to top recommendations

TRENDING

n8n - ✅(Solved) Fix bug(nodes-base): NotionTrigger stores moment.js object in staticData, causing WorkflowActivationError on every activation [1 pull requests, 1 comments, 2 participants]