Compute module use in ts code repo "No listener for query type:"

So I’ve got a node compute module registered and working with manual testing

Manual Test


Email Receipt

However when I import to use it in my TS code repo It invokes but with the following error:

INFO 
[2025-01-31T09:25:44.192119Z]
Job received - ID: b8fc4449-64ea-49f9-8e89-db01a865d6dd Query: sendEmail
INFO 
[2025-01-31T09:25:44.192125Z]
No listener for query type: sendEmail

Code Repo usage

import { sendEmail as sendEmailFromComputeModule } from "@commsforge/computemodules"; 

export type EmailThread = {
    messageId: string;
    threadId: string;
    labels?: string[];
}

...
export async function sendEmail(context: Context, event?: MachineEvent, task?: string): Promise<EmailThread> {
    console.log('[EMAIL] Starting email send process...');
    const emailData = parseEmailContext(context as unknown as ContextData);
    if (!emailData) {
        throw new Error('No email data found in context');
    }

    console.log('sending email via compute module:',
       {
           recipients: emailData.recipients,
           subject: emailData.subject,
           message: emailData.message
       }
    )

    // BUG todo figure out why this is failing due to "No listener for query type: sendEmail"

    const response: EmailThread = await sendEmailFromComputeModule({
        recipients: emailData.recipients,
        subject: emailData.subject,
        message: emailData.message
    });

    console.log('[EMAIL] Constructed email thread response:', response);

    return response;
}

I’ve gone through the docs docs/configuration/functions/using-compute-module-functions-in-ts and have the following setting:

I’m not using a @Function decorator but not sure if that is the issue, or if its perhaps related to the input/output typing? If it was type mismatch I think i’d at least get to that failure point though?

Thanks in advance - let me know if there is something obvious I am missing regarding No listener for query type: sendEmail

Figured it out. I was a bit confused about the default env vars and what i needed to set.

For some reason the module wasn’t registering correctly but i was still able to manually invoke but not use it in ts code repo…

The ones in docs examples were not in the actual list of accessible
#docs/configuration/container/container-environment-variables

fixed code:

// code
if (process.env["production"] === "true") {
  const { ComputeModule } = require("@palantir/compute-module");
  console.log('[Email Module] Initializing in production mode');
  
  const computeModule = new ComputeModule({
    logger: console,
    sources: {
      GoogleApiCodestrapme: {
        credentials: ["additionalSecretBase64EncodedSecretJson"]
      }
    }
  });

  computeModule
    .on("responsive", () => {
      console.log(`[Email Module] Responsive in production mode`);
    })
    .register("sendEmail", sendEmail);

  module.exports = { computeModule };
} else {
  console.log('[Email Module] Initializing in development mode');
  console.log('[Email Module] To run in production mode, set production=true');
  // For testing/development, export the sendEmail function directly
  module.exports = { sendEmail };
}

...

// Dockerfile

# Set production environment variables
ENV NODE_ENV=production
ENV production=true