Compute Modules return empty object intermittently

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:

The result from the function call availableTimes in Foundry shows an empty object.

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:

  1. Some side effects in compute modules are safe to run and should run as part of live preview
  2. 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.

1 Like

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?

I’m wondering if the result type is throwing off Foundry:

(error) {
Job received
const result: {
    suggested_times: {
        start: string;
        end: string;
        score: number;
    }[];
    message: string;
}

My other functions don’t exhibit this behavior but they only return simple arrays of string not object arrays.

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.

I have a couple of questions:

  1. How is it being called from TypeScript?
  2. 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

We imported the function and then call it as follows:

import { findOptimalMeetingTime } from "@gsuite/computemodules";
...
const availableTimes = await findOptimalMeetingTime(inputs);

The expected duration is less than a second. It’s a very fast call to a Google API that is executed in the compute function

What is even stranger is today the issue seems to have gone away for some reason. I haven’t been able to reproduce it yet.

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?

yes it did. I did the following:

  1. In compute modules, update the input/outputs by reimporting the inferred schema.
  2. I rebuilt my TypeSCript repo workspace
  3. I published a new version of the functions
    My understanding is these are the required steps to get the updated function spec.

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 :

  1. Delete the function from the TS in your code and in the left panel.
  2. Rebuild the workspace.
  3. Re-import the CM function.
1 Like

Will do. I’ll respond here is the issue resurfaces after following these instructions. And thank you!

1 Like

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.