# App function run time

**URL:** <https://community.dynatrace.com/t/app-function-run-time/46045>\
**Category:** Developer Q&A Forum\
**Tags:** custom-app, workflows, app-functions\
**Created:** [June 11, 2024, 10:25am UTC](https://community.dynatrace.com/t/app-function-run-time/46045 "2024-06-11T10:25:19Z")\
**Posts on this page:** 9\
**Page:** 1

<div class="post-metadata">

**Author:** ![beigert](https://dub1.discourse-cdn.com/dynatrace/user_avatar/community.dynatrace.com/beigert/32/7422_2.png) [@beigert](https://community.dynatrace.com/u/beigert)\
**Post date:** [June 11, 2024, 10:25am UTC](https://community.dynatrace.com/t/app-function-run-time/46045/1 "2024-06-11T10:25:19Z")

</div>

After deploying my appFn to dynatrace platform I’ve received this error:

```javascript
An error of type UNCAUGHT_EXCEPTION occurred in an imported library: SyntaxError: Unexpected end of JSON input
at parse (<anonymous>)
at packageData (ext:deno_fetch/22_body.js:370:14)
at consumeBody (ext:deno_fetch/22_body.js:247:12)
at eventLoopTick (ext:core/01_core.js:169:7)
at async default (file:///script.ts:5:10)

```

I didn’t expect that&nbsp;[deno](https://deno.com/)&nbsp;is the default appFn runTime. There’s no mention of that in the docs, also local development works 100% on nodeJS, and deno is not even mentioned in the lock file.

Is there any chance to deploy appFn on nodeJS runtime? If not I’ll need to rewrite all this code to be deno-compatible. Also, you have to change the:

```auto
<span>dt-app dev</span>

```

command, appFn can not be run on two different JS runtimes. Also mention in the docs that default runTime is mandatory.

---

<div class="post-metadata">

**Author:** ![stefan\_baumgart](https://dub1.discourse-cdn.com/dynatrace/user_avatar/community.dynatrace.com/stefan_baumgart/32/33707_2.png) [@stefan\_baumgart](https://community.dynatrace.com/u/stefan_baumgart)\
**Post date:** [June 11, 2024, 11:54am UTC](https://community.dynatrace.com/t/app-function-run-time/46045/2 "2024-06-11T11:54:42Z")

</div>

Hi,

Dynatrace Serverless functions run on the Dynatrace JavaScript runtime, which is a custom-made runtime for the Dynatrace AppEngine needs. Internally, we build on a fork of Deno which is mostly to ensure WebAPI compatibility (with WebAPI we mean the subset that is the de-facto standard for all back-end JavaScript runtimes like Node.js, Deno, Cloudflare workers, LLRT, Bun, and many others).

To ensure maximum compatibility with third-party libraries we are not only supporting reasonable WebAPIs, but also a subset of Node.js features. You can find out more about the compatibility features in our documentation:&nbsp;[JavaScript runtime | Dynatrace Developer](https://developer.dynatrace.com/reference/javascript-runtime/)

The TL;DR: We support everything but features related to file access, raw network connections, or multi-process handling, simply because of the way the infrastructure works and the way functions are deployed. For fetching data from an endpoint, you wouldn’t need more, though.

It would be interesting to know how your code looks like to see if this is a compatibility error or something else. Judging from the error message, you call `fetch` somewhere and expect a JSON file, but don’t get a JSON file (see&nbsp;SyntaxError: Unexpected end of JSON input).

Do you have more information?

---

<div class="post-metadata">

**Author:** ![beigert](https://dub1.discourse-cdn.com/dynatrace/user_avatar/community.dynatrace.com/beigert/32/7422_2.png) [@beigert](https://community.dynatrace.com/u/beigert)\
**Post date:** [June 11, 2024, 12:33pm UTC](https://community.dynatrace.com/t/app-function-run-time/46045/3 "2024-06-11T12:33:09Z")

</div>

There’s 2 erorrs: SyntaxError and this:

```javascript
n error of type UNCAUGHT_EXCEPTION occurred in an imported library

```

The problem was not about any missing WebAPI but with the compilation of the lib:&nbsp;[issue](https://github.com/Effect-TS/effect/issues/754)

We wanted to have more control of the workflows and with Effect.ts was able to move a lot of logic from workflow to AppFn.

Unfortunately Effect.ts team is not able to make this lib a module (.mjs) so there’s no chance to use it 😕

Btw are there any DT tools to run AppFn on Deno locally? Right now is one package (API and app). Also a plugin (or predefined rule) for Eslint will be nice.

---

<div class="post-metadata">

**Author:** ![stefan\_baumgart](https://dub1.discourse-cdn.com/dynatrace/user_avatar/community.dynatrace.com/stefan_baumgart/32/33707_2.png) [@stefan\_baumgart](https://community.dynatrace.com/u/stefan_baumgart)\
**Post date:** [June 11, 2024, 12:47pm UTC](https://community.dynatrace.com/t/app-function-run-time/46045/4 "2024-06-11T12:47:09Z")

</div>

The most important thing: The Dynatrace JS Runtime isn’t Deno.&nbsp;Are you working with the Dynatrace App Toolkit? The App Toolkit ships the Dynatrace JS Runtime so everything you develop locally in /api should work on the App Engine as well.

If you have a library that relies on CommonJS rather than EcmaScript modules it wouldn’t matter. The App Toolkit’s bundler creates one file to deploy and run regardless.

---

<div class="post-metadata">

**Author:** ![beigert](https://dub1.discourse-cdn.com/dynatrace/user_avatar/community.dynatrace.com/beigert/32/7422_2.png) [@beigert](https://community.dynatrace.com/u/beigert)\
**Post date:** [June 11, 2024, 12:49pm UTC](https://community.dynatrace.com/t/app-function-run-time/46045/5 "2024-06-11T12:49:48Z")

</div>

I’m using

```auto
<span>dt-app dev</span>

```

then test AppFn by call to localhost:3000/api

---

<div class="post-metadata">

**Author:** ![stefan\_baumgart](https://dub1.discourse-cdn.com/dynatrace/user_avatar/community.dynatrace.com/stefan_baumgart/32/33707_2.png) [@stefan\_baumgart](https://community.dynatrace.com/u/stefan_baumgart)\
**Post date:** [June 11, 2024, 1:52pm UTC](https://community.dynatrace.com/t/app-function-run-time/46045/6 "2024-06-11T13:52:59Z")

</div>

Alright, you use the Dynatrace App Toolkit. Do you have some sample code that showcases your app function? Doesn’t need to be the full thing, just to get an idea of how you use EffectTS so we can try to replicate your code and check for potential compatibility issues.

---

<div class="post-metadata">

**Author:** ![beigert](https://dub1.discourse-cdn.com/dynatrace/user_avatar/community.dynatrace.com/beigert/32/7422_2.png) [@beigert](https://community.dynatrace.com/u/beigert)\
**Post date:** [June 13, 2024, 7:38am UTC](https://community.dynatrace.com/t/app-function-run-time/46045/7 "2024-06-13T07:38:26Z")

</div>

Simple functions with EffectTS like:

> ```auto
> <span>import </span><span>{ </span>Effect<span>, </span><span>pipe </span><span>} </span><span>from </span><span>"effect"</span><span>;<br></span><span>// /api/debug.ts<br></span><span>export default async function </span><span>() {<br></span> <span>const </span>program <span>= </span><span>pipe</span><span>(<br></span> Effect<span>.</span><span>succeed</span><span>(</span><span>42</span><span>),</span><span><br></span> <span>);<br></span><span><br></span> Effect<span>.</span><span>runSync</span><span>(</span>program<span>);<br></span><span>}</span>
> 
> ```

gonna work well on localhost and throws the same error executed from the workflow.

Effect is in version 3.1.4

---

<div class="post-metadata">

**Author:** ![stefan\_baumgart](https://dub1.discourse-cdn.com/dynatrace/user_avatar/community.dynatrace.com/stefan_baumgart/32/33707_2.png) [@stefan\_baumgart](https://community.dynatrace.com/u/stefan_baumgart)\
**Post date:** [June 13, 2024, 12:48pm UTC](https://community.dynatrace.com/t/app-function-run-time/46045/8 "2024-06-13T12:48:48Z")

</div>

Hi!

I tried your code snippet and can’t reproduce your errors neither within app functions nor locally. You say you execute them from the workflow, do you package your functions as [actions](https://developer.dynatrace.com/develop/workflows/create-custom-action/)?

You can also try to execute your code within an [Ad-Hoc function in Notebooks](https://docs.dynatrace.com/docs/observe-and-explore/dashboards-and-notebooks/notebooks#code) to see if everything works out. You can load Effect from a JavaScript CDN like esm.sh and test which one of the pieces of Effect break, e.g..

```auto
import { Effect, pipe } from "https://esm.sh/effect@3.1.4";<br><br>export default async function () {<br> const program = pipe(Effect.succeed(42));<br> return Effect.runSync(program);<br>}

```

All you need to do is make sure that esm.sh is [allow-listed from your tenant](https://developer.dynatrace.com/preview/develop/functions/allow-outbound-connections/)

(Also note that esm.sh might possibly contain malicious code so I would just turn it on if you know how that CDN is used within your organisation)

---

<div class="post-metadata">

**Author:** ![MarwanC](https://dub1.discourse-cdn.com/dynatrace/user_avatar/community.dynatrace.com/marwanc/32/34480_2.png) [@MarwanC](https://community.dynatrace.com/u/MarwanC)\
**Post date:** [June 29, 2025, 3:29pm UTC](https://community.dynatrace.com/t/app-function-run-time/46045/9 "2025-06-29T15:29:59Z")

</div>

Is this supported please? I tried everywhere but no luck

import { getSecretValue } from “@dynatrace-sdk/app-runtime”; export async function getTokenFromVault(): Promise\<string\> { const secret = await getSecretValue(“my-token-secret”); return secret; }I need to save token in the vault and retrieve it like this but I can not seem to find a way?Any Idea please?Thanks in advance for your support.
