Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cannot use with esbuild based application (AWS CDK) #2664

Open
Kilowhisky opened this issue Oct 16, 2024 · 1 comment
Open

Cannot use with esbuild based application (AWS CDK) #2664

Kilowhisky opened this issue Oct 16, 2024 · 1 comment

Comments

@Kilowhisky
Copy link

Description

I'm trying to instrument custom events for nodejs based AWS ECS Tasks and Lambdas. I currently have successful lambda layer implementation but i am not able to send custom events using this method.

In order to do so i need to install newrelic into the main package.json. My AWS functions and tasks are created and managed using AWS CDK which uses esbuild in order to bundle and prepare my applications. The problem is when i attempt to import the function to record a custom event i get tons of build errors i can't seem to resolve.

I've tried all the following

import { recordCustomEvent } from "newrelic";
import newrelic from 'newrelic';
import * as NR from 'newrelic';
const NR = require('newrelic');

and they all result in these errors.

X [ERROR] No loader is configured for ".md" files: node_modules/newrelic/README.md

    node_modules/newrelic/index.js:42:22:
      42 │   const API = require(`./${apiPath}`)
         ╵                       ~~~~~~~~~~~~~~

X [ERROR] No loader is configured for ".md" files: node_modules/newrelic/THIRD_PARTY_NOTICES.md

    node_modules/newrelic/index.js:42:22:
      42 │   const API = require(`./${apiPath}`)
         ╵                       ~~~~~~~~~~~~~~

X [ERROR] Expected ";" but found "License"

    node_modules/newrelic/LICENSE:1:40:
      1 │                                  Apache License
        │                                         ~~~~~~~
        ╵                                         ;

X [ERROR] Could not resolve "split"

    node_modules/newrelic/bin/tracetractor:23:21:
      23 │   , split  = require('split')

If i use this to import

import * as NR from 'newrelic/esm-loader.mjs';

I get build warnings but it still builds. Unfortunately it won't run as it throws the following errors.

2024-10-16T16:53:55.766Z	undefined	ERROR	Unhandled Promise Rejection 	
{
    "errorType": "Runtime.UnhandledPromiseRejection",
    "errorMessage": "TypeError: Invalid URL",
    "reason": {
        "errorType": "TypeError",
        "errorMessage": "Invalid URL",
        "code": "ERR_INVALID_URL",
        "input": "lib/register.js",
        "stack": [
            "TypeError: Invalid URL",
            "    at new URL (node:internal/url:797:36)",
            "    at createHook2 (/var/task/index.js:12042:23)",
            "    at Object.<anonymous> (/var/task/index.js:12572:86)",
            "    at Module._compile (node:internal/modules/cjs/loader:1469:14)",
            "    at Module._extensions..js (node:internal/modules/cjs/loader:1548:10)",
            "    at Module.load (node:internal/modules/cjs/loader:1288:32)",
            "    at Module._load (node:internal/modules/cjs/loader:1104:12)",
            "    at cjsLoader (node:internal/modules/esm/translators:346:17)",
            "    at ModuleWrap.<anonymous> (node:internal/modules/esm/translators:286:7)",
            "    at ModuleJob.run (node:internal/modules/esm/module_job:234:25)"
        ]
    },
    "promise": {},
    "stack": [
        "Runtime.UnhandledPromiseRejection: TypeError: Invalid URL",
        "    at process.<anonymous> (file:///var/runtime/index.mjs:1276:17)",
        "    at process.emit (node:events:519:28)",
        "    at process.wrappedEmit [as emit] (/opt/nodejs/node_modules/newrelic/lib/instrumentation/core/globals.js:53:23)",
        "    at emitUnhandledRejection (node:internal/process/promises:250:13)",
        "    at throwUnhandledRejectionsMode (node:internal/process/promises:385:19)",
        "    at processPromiseRejections (node:internal/process/promises:470:17)",
        "    at process.processTicksAndRejections (node:internal/process/task_queues:96:32)"
    ]
}

Your Environment

  • ex: Browser name and version: AWS Lambda / ECS (Docker)
  • ex: Node version: LTS
@workato-integration
Copy link

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
Status: Triage Needed: Unprioritized Features
Development

No branches or pull requests

1 participant