Race condition between change and load hooks

Feature(s) impacted

Hooks in a smart action.

Observed behavior

    {
      name: 'Example',
      endpoint: '/forest/actions/example',
      type: 'single',
      fields: [
        {
          field: 'ok',
          type: 'Boolean',
          isRequired: true,
          defaultValue: true,
          hook: 'onOkChange',
        },
        {
          field: 'displayName',
          type: 'String',
        },
      ],
      hooks: {
        load: async function ({ fields }) {
          console.log('LOAD START');
          await sleep(1000);
          console.log('LOAD DONE');
          return fields;
        },
        change: {
          onOkChange: async function ({ fields }) {
            console.log('OK START');
            await sleep(1000);
            console.log('OK DONE');
            return fields;
          },
        },
      },
    },

When I open the smart action form, both load and change hooks are fired concurrently. Depending on the order they complete, one overwrites the other.

Expected behavior

  • No change hook should be fired when opening the form.
  • If both really need to be fired, I would expect the change hook to wait for the load hook to complete before starting.

Context

  • Project name: Evy
  • Team name: Operations
  • Environment name: Dev
  • Agent technology: nodejs
  • Agent (forest package) name & version: forest-express-sequelize 9.5.4
  • Database type: PostgreSQL

Hello @antoineww

Sorry for the late reply, we were able to reproduce the issue, it occurs when the defaultValue and hook properties are defined on a field. A bug report has been created and will be fixed ASAP.

I’ll keep you updated when the fix has been released.

Thanks for the report.

Best regards,

1 Like

Hello @antoineww,

The fix has been merged, could you refresh your browser and confirm that it solves your issue ?