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

Getting error: ❗️Uncaught TypeError: Cannot read properties of undefined (reading 'code') when running the the application localy #91

Closed
gopalanand333 opened this issue Feb 7, 2024 · 5 comments

Comments

@gopalanand333
Copy link

Hi Team,
I have installed the plugin version "0.0.3". When i am running the command cds watch, i am getting the following error


[cds] - ❗️Uncaught TypeError: Cannot read properties of undefined (reading 'code')
    at onDone (/home/user/projects/incidents-app/node_modules/@cap-js/telemetry/lib/tracing/trace.js:229:23)
    at <anonymous>
    at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
TypeError: Cannot read properties of undefined (reading 'code')
    at onDone (/home/user/projects/incidents-app/node_modules/@cap-js/telemetry/lib/tracing/trace.js:229:23)
    at /home/user/projects/incidents-app/node_modules/@cap-js/telemetry/lib/tracing/trace.js:239:7
    at NoopContextManager.with (/home/user/projects/incidents-app/node_modules/@cap-js/telemetry/node_modules/@opentelemetry/api/build/src/context/NoopContextManager.js:25:19)
    at ContextAPI.with (/home/user/projects/incidents-app/node_modules/@cap-js/telemetry/node_modules/@opentelemetry/api/build/src/api/context.js:60:46)
    at trace (/home/user/projects/incidents-app/node_modules/@cap-js/telemetry/lib/tracing/trace.js:218:27)
    at OKRAService.process (/home/user/projects/incidents-app/node_modules/@cap-js/telemetry/lib/tracing/okra.js:33:12)
    at OData.process (/home/user/projects/incidents-app/node_modules/@sap/cds/libx/_runtime/cds-services/adapter/odata-v4/OData.js:264:24)
    at Layer.handle [as handle_request] (/home/user/projects/incidents-app/node_modules/express/lib/router/layer.js:95:5)
    at trim_prefix (/home/user/projects/incidents-app/node_modules/express/lib/router/index.js:328:13)
    at /home/user/projects/incidents-app/node_modules/express/lib/router/index.js:286:9
    

Not sure if it's the app or framework.

incidents https://github.com/cap-js/incidents-app
Node.js v18.14.2
@sap/cds 7.6.1
@sap/cds-compiler 4.5.0
@sap/cds-dk 7.5.0
@sap/cds-dk (global) 7.5.1
@sap/eslint-plugin-cds 2.6.4
@sap/cds-mtxs 1.14.0
@gopalanand333
Copy link
Author

Another error:

[telemetry] - Error: @opentelemetry/api: Registration of version v1.7.0 for trace does not match previously registered API v1.4.1
    at registerGlobal (/home/user/projects/incidents-app/node_modules/@opentelemetry/api/build/src/internal/global-utils.js:38:21)
    at TraceAPI.setGlobalTracerProvider (/home/user/projects/incidents-app/node_modules/@opentelemetry/api/build/src/api/trace.js:54:59)
    at NodeTracerProvider.register (/home/user/projects/incidents-app/node_modules/@opentelemetry/sdk-trace-base/build/src/BasicTracerProvider.js:92:21)
    at NodeTracerProvider.register (/home/user/projects/incidents-app/node_modules/@opentelemetry/sdk-trace-node/build/src/NodeTracerProvider.js:43:15)
    at module.exports (/home/user/projects/incidents-app/node_modules/@cap-js/telemetry/lib/tracing/index.js:119:18)
    at module.exports (/home/user/projects/incidents-app/node_modules/@cap-js/telemetry/lib/index.js:22:3)
    at Object.<anonymous> (/home/user/projects/incidents-app/node_modules/@cap-js/telemetry/cds-plugin.js:1:48)
    at Module._compile (node:internal/modules/cjs/loader:1254:14)
    at Module._extensions..js (node:internal/modules/cjs/loader:1308:10)
    at Module.load (node:internal/modules/cjs/loader:1117:32)

@sjvans
Copy link
Contributor

sjvans commented Feb 7, 2024

hi @gopalanand333

i don't encounter these errors. please provide steps to reproduce.

thanks,
sebastian

@pankajinnitk
Copy link

@sjvans : We get the same error (❗️Uncaught TypeError: Cannot read properties of undefined (reading 'code')) in our apps for which we have set up a call with you for today. For us this is not reproducible in our local

@sjvans
Copy link
Contributor

sjvans commented Feb 7, 2024

with fresh node_modules, the issue doesn't occur anymore

@sjvans sjvans closed this as completed Feb 7, 2024
@pankajinnitk
Copy link

pankajinnitk commented Feb 9, 2024

Hi @sjvans ,

This problem is still reproducible for our multiple apps. We have also upgraded our otel libraries which did not help.
Please find more more details which may be helpful for you to fix the same .
This problem seems to occur for missing handling for below type of traces which are marked as non-recording via sampler or suppressed via ignore path.

  • Instrumentation suppressed, returning Noop Span
  • Recording is off, propagating context in a non-recording span

Hence it did not occur in localhost for us. However now we are able to reproduce in localhost as well.
In case you want to reproduce in localhost you can try below 2 options:

  1. In package.json add ignore path for say $batch calls (just to simulate the suppression of trace)
    "instrumentations": {
    "http": {
    "module": "@opentelemetry/instrumentation-http",
    "class": "HttpInstrumentation",
    "config": {
    "ignoreIncomingPaths": [
    "/model/$batch"
    ]
    }
    }
    }
    Now this will result in reported exception.

  2. Change sampling decision in debugger for one of the spans for $batch call in localhost
    Code -> node_modules/@opentelemetry/sdk-trace-base/build/src/Tracer.js -> line no 88. In debug set the samplingResult.decision to 0 i.e. NOT_RECORD .
    Post this when the call will reach
    node_modules/@cap-js/telemetry/lib/tracing/trace.js line no 229 , it will result in exception as such Non Recording spans do not have status in them.

image image

Hope these details help you fix the problem

Regards,
Pankaj

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants