Transformer fails before module loads

I'm using a module for my topNav bar, and since it can hold outputs, I'm using it to run similar data fetches from APIs, databases, etc in the same way for all my "pages" (apps) in the app.

I have an app that uses a transformer that's based on the outputs of that module, and when I load the page, the transformer fails immediately b/c the module is still loading, which I would expect, but it doesn't fix itself once the module has loaded, which I do not expect...

If I alter the code in some meaningless way, and save, then the transformer works fine, and the app runs. Until then, it seems to "give up" after that initial failure and doesn't respond to the updated inputs.

Should I not be keying transformers off of module outputs when they're async?

Thanks in advance for your thoughts.

Hey pyee! I've just tested a transformer making an external reference to a module output, albeit with a fast query and a single text component in the module. The premise is sound though!

Is your module taking a perceptibly long time to load with lots of components/queries? Have you tried putting the transformer in the module itself, and passing its value into the module output?

Thanks for the reply, @ryanm !

  1. The module takes 3-6s to run its queries (external API calls) and it does have some transformers of its own that it calls to prepare the data that all the other apps will use. It doesn't have a ton of components, but the API isn't instantaneous, so there is an async dynamic.

  2. The original idea was to prepare only the common data in the module, and then each app could have its unique transformers to prepare the data for what it needs, so those specific calcs/joins/transformations wouldn't have to be done EVERY time for ALL apps when the module loads. I think your method would work, but isn't as efficient, and will increase the load time of every app if I add more functionality to any app.

I was hoping to understand better why the individual transformers in the app are seemingly not responding to changes in the module output values by updating themselves.

When I build the app the first time, I can write a transformer based on module output, and everything works. But when I reload the app, the transformer can't see any data initially, so returns null, even though the preview button on the transformer shows data (after the module loads). My guess is that the transformer is not monitoring the output changes on the module in the same way it monitors the outputs of other elements, and it's not refreshing itself once the module finishes loading.

@pyee I'm having the same thing. It seems more like the output of a module causing app components to behave oddly. I was first trying to put the output of one module in a dummy query in the app so that the dummy query could trigger something else. But, even though the output of the module is undoubtedly changing, the query fails to see the changes. I then tried to put the module output into a transformer and then use the transformer data to auto trigger the dummy query. Same thing happens. The transformers value is clearly changeling. If I preview the transformer, it contains data. But, from the context of the query that is referencing its values, it isn't the same.

module outputs

Same as you described, as seen in the gif, once I save the transformer without actually changing it, everything starts functioning as expected.

@shawncrocker , glad to hear I'm not the only one! What workaround have you implemented? I've resorted to making the transformers javascript queries and sprinkled triggers everywhere to make them fire. It's not clean, and it's hard to make it run really efficiently (triggers get called too many times), but it's functional...

@pyee I have added a few more things into my modules then I wanted to to get around it. I was hoping to create sort of like a processor that processed any list of items the same way using an assortment of queries and resources. I was wanting to feed module data into this processor module and then again, feed processed items back into the app or other modules. Now I just have each module that needs items processed done within itself. Kind of sucks but they all still use library queries so not super bad. Not nearly as awesome though. I am hoping this gets caught as a bug.

Hey @Shawn_Crocker!

Would you mind if I took a closer look at your module/app as well? I was able to see @pyee's a bit but unfortunately I still haven't been able to reproduce the behavior based on it :pensive:

@Kabirdas Sorry I missed your response here. If you could take a look that would be great!. How should I give access to the apps and modules? BTW, It isn't just transformers. For instance, I have a module that has an output set to the selected row of the table it contains. I have this in an app. I also have another module in the same app that has an input. If I set the input of this module to the output of the other module, everything works fine. Then when I reload the app, from the context of second modules input, the output of the first module will be evaluating to null. as soon as I delete a character and then just type it back in, everything is working again.

Here is a nice simple demo of what I just said in the ubove post.

2023-04-25 13-40-03

As soon as I delete one character from the mini script and then put the same character back in, the module starts resolving with the input data.

Hey @shawncrocker!

Thanks for letting us take a look at your app. I've been able to repro the behavior and let the dev team know - I'll report back here when the behavior has been fixed. In the meantime, you might try recreating the module to see if that fixes the issue.

Otherwise, if recreating the module doesn't work and you're really blocked on this another more complex thing to try is to fetch the outputs manually. You can do this by adding an input query to your module:

Creating JavaScript query that references your module outputs:

And then pass that query to your module so that you can trigger it from the module itself:

Can you let me know if either of those work?

Thanks @Kabirdas Great to here there maybe an immediate work around. I struggle with grasping the module queries and exactly what they are doing. To clarify my understanding, the method you have described will take and output from one module and pass it into the input of another? So, one module has output data. In the app, I will reference that output data in a JavaScript query that just returns it on trigger. In the other module, there will be an input that is set to be a query. In the app, that modules query input will be set to reference the JS query. If that is the correct understanding, the thing I am unsure of is, what triggers the JS query to return is data? and when the JS query triggers, does that mean the modules input query will also automatically trigger and pull in the data?

@Kabirdas Ya, so I appear to have crippling lack of understanding into the module query. It just doesn't seem to be doing anything when the parent query fires. Does the parent query's .data get passed into the module query? This is what I am thinking should be happening. I have the module query setup to onSuccess, run a script that sets some states to the values returned by the module query. It just seems like nothing happens when the parent fires.

@Kabirdas So I splashed some cold water on my face and reread what you said. Suddenly I realized module queries trigger the parent query. The parent query does not trigger the module. This information in a module query itself is being called out completely the opposite in a module query.

Capture

So now everything is working as expected except the JS query also does not seem to be able to read the modules output initially after reloading the app. Anyway, I am glad I figured out the modules queries because they seem very useful.

Edit:

Just an update. I went into the module that is outputting data and purposefully created a mis named reference in the output. I then re-entered the correct reference name. When I went back into the parent and refreshed, the JS query is seeing the data from the output even on initially loading the app. So for now, it seems things are working.

Good to hear that it's working for now @shawncrocker, sorry that it's such an involved workaround but glad you were able to get it working. Will definitely let you know here when there's a fix for the issue! Please let me know if it stops working too.

@Kabirdas Yes I'm glad I am getting the modules to function as I need. Now that I have started using them, bugs aside, I just can't go back. They are defiantly the answer to a struggle I have had with over complicating an app. As an app is used and worked on, more and more functionality keeps creeping in and before you realize, you have something that does lots of useful stuff very slowly. And the complexity makes is so hard to improve performance without breaking stuff. Modules do seem to be the answer to nicely compartmentalizing additional functionality that may need to be added to a tool.

@pyee @shawncrocker a fix for this went out with the 2.120.0 release today! Could yall let me know if the error is still showing up for you?

1 Like

@Kabirdas , yes, it seems that transformers are now picking up the changes to the module outputs as they change without needing the input query workaround. Appreciate the fix! This will simplify a bunch of things on my end!

I'm also noticing that it's adding the "loading" graphic to components that are dependent on the transformer that's dependent on my module outputs, so that's nice as well.

Good work, dev team!

1 Like

This seems to be working great now @Kabirdas. Thanks for updating us. I have run some quick tests and using a modules output seems to evaluate fine everywhere in an app even after freshly loading the app. This really does take a lot of headache out of creating peculiar data pathways.

1 Like