Use of getWorkflowStaticData in trigger node

Hello n8n community,

I need help regarding the use of getWorkflowStaticData with ITriggerFunctions

My use case: I need to write a trigger node that could perform time based polling over an SFTP server and fetch files uploaded with in last x time.

For this I am trying to save time pointer in workflow staticData.
here is code snippet of what I am trying to do

async trigger(this: ITriggerFunctions): Promise {
const executeTrigger = async () => {
// create sftp connection
// fetch list of files

		const staticData = this.getWorkflowStaticData('node');
		if (!staticData.lastCheckpoint) {
			// logic for first run
		} else {
			const lastCheckpoint = staticData.lastCheckpoint as number;
			// use lastCheckpoint to filter/produce results 
		staticData.lastCheckpoint = new Date().getTime()
		// emit list of eligible files
	// set cron expression as per need and start job
	let cronJob: CronJob;
	cronJob = new CronJob(cronTime, await executeTrigger, undefined, true, this.getTimezone());
	async function closeFunction() {
	return {


This works fine as long as workflow is active but if I deactivate and reactivate the same workflow, it looses staticData (its not being persisted in db). Any pointers on this ? how to workaround this ?

NOTE: I am able to perform this same thing with a regular node (with IExecuteFunctions) and with regular node I can see static data being saved in DB.


Yes that is true. It was designed to only save the static data once after the trigger node got activated.
The reason for that is, that it was initially mainly used to save webhook related data. I changed it now to also save the static data after each “emit” (at least if the data got changed). So if you pull the latest code from the Github repository, it should now work fine.

Thanks a lot @jan, you guys are really amazing, super helpful !!

Great the hear! Have fun!