When calling a compute module function from a TypeScript function, you will receive an empty object as a response (intermittently). I can see my compute module is returning the expected result, but for some reason, in Foundry, it shows up as an empty object.
Compute module logs showing the JSON being returned:
I think this is due to the sandbox for live preview. While I think it’s good not to cause side effects in compute modules, could you add a configuration that lets the user override this behavior? This solves two problems:
Some side effects in compute modules are safe to run and should run as part of live preview
It will document the live preview behavior in a way that is clear to the module author
Also the fact the behavior is intermittent is very strange. Sometimes I get the results, sometimes I do not, but in all cases my compute module is returning a valid result. The feels like a bug in the platform.
I actually think this might be an issue with the compute module code. I added additional logging, and it looks like the top-level call to the function was missing await.
Adding the await did not solve this issue of compute modules intermittently returning and empty object. It’s actually really hard to get it to return a result to my TypeScript functions. Below you can see that the function did return a result. Somehow though my TypeScript function gets an empty object.
I’ve confirmed this issue happens in live functions as well. I can’t figure out why though. Can someone on the functions team troubleshoot this with me?
Another possible root cause might be the fact that my calling TypeScript functions are in a different project than my compute module. But this should only effect live preview, not published functions. This issue is present in both.
This is so strange. I have made zero changes and this morning I am unable to reproduce this issue. I could really use some help from the functions team to understand what could possible cause this type of transient issue.
What is the expected duration for the query to complete?
The reason for these questions is that in TypeScript, it calls the synchronous endpoint of the CM, causing it to wait for the result for up to 2 minutes (we can extend this to 5 minutes). However, if it got dispatch in the module but the module takes 3 min to execute ts will not wait for the execution result (also if ts function has a timeout of 60 sec and function takes 2 min then we never wait for the return value)
For instance if your CM is loaded and takes too long in the queue ts function will not wait for the result, that is maybe what was happening
Given your information the issue seems unrelated to execution behavior.
The only other problem I can think of, it might be linked to modifying the compute module’s definition while the TS function has it imported. Did your CM function definition change while it was imported in function ts panel?
That could be why, currently tracking this issue that someone pointed out. Since versioning is not supported on CM functions this can cause a problem
To resolve this, we recommend right now until this gets fixed that every time you change the CM function definition, you perform the following steps in TS function :
Delete the function from the TS in your code and in the left panel.