-
Notifications
You must be signed in to change notification settings - Fork 487
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 - TypeError: Cannot read properties of undefined (reading 'forEach') #1950
Comments
If you remove the otel instrumentation, does the issue persist? I am not confident that this is an issue caused by otel. |
The app runs completely fine without otel instrumentation, removing the |
Thanks for the extra info 👍 I've marked it as P1 as it's causing an error in end-user apps. Like many open-source projects we have a limited bandwidth so a more minimal reproducer would be immensely useful and would allow us to tackle that issue more quickly. |
No worries, I am still debugging this myself as well, will update the issue if I find something. Also tracking this in the Upstream project I am instrumenting https://github.com/orgs/Unleash/discussions/6455 |
Some extra context on this after checking out the project ad try it myself
# install dependencies based on the lock file & build
yarn && yarn build
# start db
docker compose up -d postgres
# start the app with the required env (for app & OTEL)
NODE_OPTIONS="--require @opentelemetry/auto-instrumentations-node/register" \
OTEL_EXPORTER_OTLP_PROTOCOL="grpc" \
OTEL_NODE_RESOURCE_DETECTORS="env,host,container" \
OTEL_SERVICE_NAME="my-demo" \
OTEL_PROPAGATORS="tracecontext,baggage,b3" \
OTEL_RESOURCE_ATTRIBUTES="k8s.container.name=unleash,k8s.deployment.name=my-demo,k8s.namespace.name=my-unleash,k8s.replicaset.name=my-demo-f95cddd45,service.version=v5.9.6-20240221-210653-d96e3be" \
DATABASE_USERNAME=unleash \
DATABASE_PASSWORD=unleash \
DATABASE_NAME=unleash \
DATABASE_HOST=localhost \
DATABASE_SSL=false \
INIT_ADMIN_API_TOKENS=*:*.unleash4all \
GOOGLE_IAP_AUDIENCE=/projects/123/global/backendServices/123 \
node ./dist/index.js
Express instrumentation may be affecting/modifying some route internals. The code throwing the error is from |
Code checking for that prop is here: Edit: router handler has some properties that get hidden when patching it. By having them exposed as properties of the patched function these libs that make use of them could work properly. I'm going to create a PR for this one with a proposal @Starefossen cc: @pichlermarc |
What happened?
Steps to Reproduce
Follow the guide for automatic instrumentation: https://opentelemetry.io/docs/languages/js/automatic/
The source code for this application is here: https://github.com/nais/unleash/tree/unleash-v5 and is based on
express
^4.18.2
.Environment variables:
Expected Result
It should start properly.
Actual Result
Application
Additional Details
OpenTelemetry Setup Code
// automatic instrumentation
package.json
Relevant log output
The text was updated successfully, but these errors were encountered: