cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Using 3rdparty modules in js runtime.

DantePaoloni
Observer

Hello development team!

The last time I read about JS runtime limitations, I remember the ability to import third-party modules for use in applications and/or workflow tasks. Reading again, https://developer.dynatrace.com/reference/javascript-runtime/ seems like there is much more limited support for importing third party modules.

My use case is to use cheerio to extract information from a scrap via fetch and send the value to a metric. Is something like that not possible? Since the moment that I call the cheerio function I get the following error:

An error occurred: {"code": 541, "message": "Execution crashed.", "details": {"type": "BAD_REQUEST", "message": "<stripped secret anyhow::Error>"}}

Thanks in advance 🙂 

4 REPLIES 4

sinisa_zubic
Dynatrace Champion
Dynatrace Champion

Hi @DantePaoloni 

Yes the JS runtime has some limitations when it comes to 3rd party modules. 

 

I have tried to reproduce your problem. loading data via fetch and using cheerio to extract it. This is my code snippet, it works without any problems

import * as cheerio from "cheerio";

export default async function (payload: unknown = undefined) {
  const resp = await fetch("https://example.com/");
  const txt = await resp.text();
  const $ = cheerio.load(txt);
  console.log($("title").text());
  return $("h1").text();
}

 

Maybe you can share your AppFunction code with us?

 

Best,
Sini

If I'm interpreting the error@DantePaoloni  shared correctly, he might be using the "Run Javascript" action in Workflows, which currently doesn't support 3rd party libraries.

Your AutomationEngine ally!

Hey, I was re checking again just in case. Indeed is a JS Action in a workflow.

Will eventually be supported? Or this is be something to create in  an AppFunction and call it throught a workflow like in https://developer.dynatrace.com/develop/functions/create-function/#from-notebooks-or-workflows ? Im asking in this case the "right" way to handle it.

Yes, as of now that would be the workaround.

There have been plans to add 3rd packages support for functions in workflows and notebooks but I don't have any further details on that. 

Featured Posts