"Error thrown in the snapshot context" when calling "forge deploy"

I have got an error when I tried to deploy my app. The “hello world” app works fine. But when I added my app logic, it cannot be deployed. The error is like this:

pengxiao@pengs-air mdx-confluence % forge deploy
Deploying your app to the development environment.
Press Ctrl+C to cancel.

Running forge lint...
No issues found.

✕ Deploying mdx-confluence to development...

ℹ Packaging app files
ℹ Uploading app
ℹ Validating manifest
ℹ Snapshotting functions

Error: Error thrown in the snapshot context.
App code snapshot error: Snapshot error occurred: Error: Code generation from strings disallowed for this context
Learn more about the snapshot context at http://go.atlassian.com/forge-snapshot-context.

Rerunning the command with --verbose may give more details.

If I understand it correctly, this is related to “eval()”, which might be the case given the function that I am trying. Is the a configuration that can ignore this warning? I have already tried “permissions:content:unsafe-eval”.

After enabled “–verbose”, it printed this following error:

        "description": "Snapshotting functions",
        "events": [
          {
            "__typename": "AppDeploymentTransitionEvent",
            "stepName": "Generate snapshot step",
            "createdAt": "2021-04-08T12:28:41.417Z",
            "newStatus": "STARTED"
          },
          {
            "__typename": "AppDeploymentLogEvent",
            "stepName": "Generate snapshot step",
            "createdAt": "2021-04-08T12:28:55.008Z",
            "message": "Snapshot error occurred: Error: Code generation from strings disallowed for this context\nValidation errors: {\n  \"stack\": [\n    \"Error: Snapshot error occurred: Error: Code generation from strings disallowed for this context\",\n    \"    at /var/task/index.js:36047:27\"\n  ]\n}",
            "level": "WARNING"
          },
          {
            "__typename": "AppDeploymentTransitionEvent",
            "stepName": "Generate snapshot step",
            "createdAt": "2021-04-08T12:28:55.010Z",
            "newStatus": "FAILED"
          }
        ]

Hi @eagle.xiao ,

Do you mind sharing what you need to do with eval()? We try to limit what gets executed during snapshotting to maintain security between instances.

Hi @mventnor , I am build an application on top of mdx (https://mdxjs.com/). It won’t surprise me if mdx needs to eval the embedded JavaScript.

MDX is an authorable format that lets you seamlessly write JSX in your Markdown documents. You can import components, such as interactive charts or alerts, and embed them within your content. This makes writing long-form content with components a blast :rocket:.

Hi @eagle.xiao, are you still running into this eval error when you try deploy with snapshotting enabled?