Skip to content

[BUG]: Angular SSR with datadog crash in runtime #7012

@rui-ad-monte

Description

@rui-ad-monte

Tracer Version(s)

5.80.0

Node.js Version(s)

22.21.1, 24.11.1

Bug Report

Initializing Datadog in express with Angular SSR, crashes in runtime due to Angular rendering engine.

The building pass and initializing the "server" works until it reach an Angular endpoint that executes the angular rendering engine.

Reproduction Code

Simple example repo fresh Angular@21 w/ SSR + dd-trace
https://github.com/rui-ad-monte/bug-angular-ssr-datadog

Error Logs

@rui-ad-monte ➜ /workspaces/bug-angular-ssr-datadog (main) $ npm run start

> [email protected] start
> ng serve

Browser bundles     
Initial chunk files  | Names            |  Raw size
main.js              | main             |  48.46 kB | 
styles.css           | styles           |  96 bytes | 

                     | Initial total    |  48.56 kB


Server bundles      
Initial chunk files  | Names            |  Raw size
main.server.mjs      | main.server      |  49.73 kB | 
server.mjs           | server           |   1.84 kB | 
polyfills.server.mjs | polyfills.server | 243 bytes | 

Application bundle generation complete. [5.187 seconds] - 2025-11-28T14:46:51.310Z

Watch mode enabled. Watching for file changes...
NOTE: Raw file sizes do not reflect development server per-request transformations.
  ➜  Local:   http://localhost:4200/
  ➜  press h + enter to show help
✘ [ERROR] Could not resolve "graphql/language/visitor"

    node_modules/dd-trace/packages/datadog-plugin-graphql/src/tools/transforms.js:8:26:
      8 │ const visitor_1 = require("graphql/language/visitor");
        ╵                           ~~~~~~~~~~~~~~~~~~~~~~~~~~

  You can mark the path "graphql/language/visitor" as external to exclude it from the bundle, which
  will remove this error and leave the unresolved path in the bundle. You can also surround this
  "require" call with a try/catch block to handle this failure at run-time instead of bundle-time.

✘ [ERROR] Could not resolve "graphql/language/printer"

    node_modules/dd-trace/packages/datadog-plugin-graphql/src/tools/transforms.js:9:26:
      9 │ const printer_1 = require("graphql/language/printer");
        ╵                           ~~~~~~~~~~~~~~~~~~~~~~~~~~

  You can mark the path "graphql/language/printer" as external to exclude it from the bundle, which
  will remove this error and leave the unresolved path in the bundle. You can also surround this
  "require" call with a try/catch block to handle this failure at run-time instead of bundle-time.

✘ [ERROR] Could not resolve "graphql/utilities"

    node_modules/dd-trace/packages/datadog-plugin-graphql/src/tools/transforms.js:10:28:
      10 │ const utilities_1 = require("graphql/utilities");
         ╵                             ~~~~~~~~~~~~~~~~~~~

  You can mark the path "graphql/utilities" as external to exclude it from the bundle, which will
  remove this error and leave the unresolved path in the bundle. You can also surround this
  "require" call with a try/catch block to handle this failure at run-time instead of bundle-time.

/workspaces/bug-angular-ssr-datadog/node_modules/vite/node_modules/esbuild/lib/main.js:1467
  let error = new Error(text);
              ^

Error: Error during dependency optimization:

✘ [ERROR] Could not resolve "graphql/language/visitor"

    node_modules/dd-trace/packages/datadog-plugin-graphql/src/tools/transforms.js:8:26:
      8 │ const visitor_1 = require("graphql/language/visitor");
        ╵                           ~~~~~~~~~~~~~~~~~~~~~~~~~~

  You can mark the path "graphql/language/visitor" as external to exclude it from the bundle, which will remove this error and leave the unresolved path in the bundle. You can also surround this "require" call with a try/catch block to handle this failure at run-time instead of bundle-time.


✘ [ERROR] Could not resolve "graphql/language/printer"

    node_modules/dd-trace/packages/datadog-plugin-graphql/src/tools/transforms.js:9:26:
      9 │ const printer_1 = require("graphql/language/printer");
        ╵                           ~~~~~~~~~~~~~~~~~~~~~~~~~~

  You can mark the path "graphql/language/printer" as external to exclude it from the bundle, which will remove this error and leave the unresolved path in the bundle. You can also surround this "require" call with a try/catch block to handle this failure at run-time instead of bundle-time.


✘ [ERROR] Could not resolve "graphql/utilities"

    node_modules/dd-trace/packages/datadog-plugin-graphql/src/tools/transforms.js:10:28:
      10 │ const utilities_1 = require("graphql/utilities");
         ╵                             ~~~~~~~~~~~~~~~~~~~

  You can mark the path "graphql/utilities" as external to exclude it from the bundle, which will remove this error and leave the unresolved path in the bundle. You can also surround this "require" call with a try/catch block to handle this failure at run-time instead of bundle-time.


    at failureErrorWithLog (/workspaces/bug-angular-ssr-datadog/node_modules/vite/node_modules/esbuild/lib/main.js:1467:15)
    at /workspaces/bug-angular-ssr-datadog/node_modules/vite/node_modules/esbuild/lib/main.js:926:25
    at /workspaces/bug-angular-ssr-datadog/node_modules/vite/node_modules/esbuild/lib/main.js:1345:9
    at process.processTicksAndRejections (node:internal/process/task_queues:105:5) {
  errors: [Getter/Setter],
  warnings: [Getter/Setter]
}

Node.js v22.21.1

Tracer Config

With default is possible to reproduce

import 'dd-trace/init';

Operating System

No response

Bundling

Vite

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions