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

Node Handler check, is not handling mjs file extension bug #198

Open
Engerim opened this issue Feb 27, 2024 · 1 comment
Open

Node Handler check, is not handling mjs file extension bug #198

Engerim opened this issue Feb 27, 2024 · 1 comment
Assignees
Labels
bug Something isn't working

Comments

@Engerim
Copy link

Engerim commented Feb 27, 2024

Description

The node handler check is not handling the file extension for esm modules (mjs) correctly, so you always see as an error in aws lambdas, and this is misleading
Startup check failed: missing handler file newrelic-lambda-wrapper.handler (NEW_RELIC_LAMBDA_HANDLER=src/handler.sqsHandler)

Steps to Reproduce

  • use nr lambda layers
  • have a mjs file as a handler
  • NEW_RELIC_USE_ESM env is set to true
  • the check will print this error Startup check failed: missing handler file newrelic-lambda-wrapper.handler (NEW_RELIC_LAMBDA_HANDLER=src/handler.sqsHandler)

Expected Behavior

  • the check should not print the error

Additional context

  • the tests are passing as this part is not tested in the code

A Patch for the test setup like it happens when you use the nr lambda layers and the setup
this patch let the test fails as it really runs through the code

Index: checks/handler_check_test.go
IDEA additional info:
Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
<+>UTF-8
===================================================================
diff --git a/checks/handler_check_test.go b/checks/handler_check_test.go
--- a/checks/handler_check_test.go	(revision 039e826cac93eb276be1e614485ae38721cdd4f3)
+++ b/checks/handler_check_test.go	(date 1709044901494)
@@ -110,8 +110,9 @@
 	os.MkdirAll(filepath.Join(handlerPath, "path", "to"), os.ModePerm)
 	os.Create(filepath.Join(handlerPath, "path", "to", "app.mjs"))
 
-	reg.Handler = testHandler
-	conf.NRHandler = config.EmptyNRWrapper
+	reg.Handler = "newrelic-lambda-wrapper.handler"
+	os.Setenv("NEW_RELIC_USE_ESM", "true")
+	conf = config.Configuration{TestingOverride: false, NRHandler: testHandler}
 	err = handlerCheck(ctx, &conf, &reg, r)
 	assert.Nil(t, err)
 }
@Engerim Engerim added the bug Something isn't working label Feb 27, 2024
@chaudharysaket chaudharysaket self-assigned this Mar 19, 2024
@workato-integration
Copy link

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

3 participants