Smart Segment Data Loading Issue


I have just added some Smart Segments. They behave perfectly but there seems to be an issue with data loading.

Expected behavior

Smart Segments should reload data every time I refresh the page or change the segment.

Actual behavior

Smart Segments load data only when server is restarted.


Segments created directly on forestadmin work without any issue. Only the ones created in the collection have the above mentioned behaviour.

  • Package Version: forest-express-sequelize 7.6.3
  • Express Version: 4.17.1
  • Sequelize Version: 5.8.9
  • Database Dialect: postgres
  • Database Version: 12
  • Project Name: Kokoon.1

I’ll try to reproduce this.
I keep you updated once done

OK i’ve been toying with segments for a couple minutes, and I’m not sure I understand the issue that you are having.

Which segments implementation are you using?

  • Smart segments: write javascript code in your agent.
  • Query segments: write SQL code in the interface.
  • Simple segments: build filters using dropdowns in the interface.

Changing the definition of a smart segment in an agent that runs on your local machine requires restarting it for NodeJS to see the changes, but that is also true to any code modification in any NodeJS program.

Can you show me some code and explain your use-case so that I understand your issue better?

I’m using Smart Segments. For the moment I’ve gone back to Simple Segments.

Here’s an example of how I’ve implemented the Smart Segments:

segments: [
		name: 'segment_name',
		where: async () => {
			const ids = await models.model_name.findAll({where : { condition }})
				.then((res: any) => any) =>

			return { id: { []: ids }}

What do you mean when you ask “Smart Segments should reload data every time I change the segment.”?

Do you mean restarting the NodeJS process automatically when you edit the source file?

Let’s take an example:

  • Record: Rec,
  • Segments Seg_A, Seg_B …
  • Smart Actions: Act_A, Act_B …

Seg_A is active in State A of Rec, Seg_B is active in State B of Rec…

Act_A is only active in Seg_A, Act_B is only active in Seg_B, …

Initially Rec is State A.
Act_A transitions Rec into State B, Act_B transitions Rec into State C …

The above described behaviour occurs without a problem with SImple Segments.

But with Smart Segments:
Act_A transitions Rec to State B but Seg_A stays active despite Rec being in State B. and it requires a restart for Seg_B to activate and so on…