cancel
Showing results for 
Search instead for 
Did you mean: 

TypeError: Cannot read properties of undefined (reading '_initial')

sridhar_thiyagarajan
Participant
0 Kudos

Hello,

We are facing the below error when @sap/cds library is upgraded from 5.9.5 to 6.6.2. There are three related modules and their dependencies and development dependencies of package.json are as follows:

Module-3 (ppbr-job-integrator) have dependencies on both Module-1 (ppbr-monitoring) and Module-2 (ppbr-integration-common) and below dependency works fine with library version of @sap/cds as 5.9.5.

Node version: 16.19.0

Module-1:
"dependencies": {
"@sap/cds": "5.9.5",
"reflect-metadata": "0.1.13"
}

"devDependencies": {
"@sap/cds-dk": "6.1.1",
"@types/eslint": "8.4.2",
"@types/jest": "27.5.1",
"@types/node": "17.0.35",
"@types/prettier": "2.6.1",
"@typescript-eslint/eslint-plugin": "5.25.0",
"@typescript-eslint/parser": "5.25.0",
"cds2types": "2.7.2",
"eslint": "8.16.0",
"eslint-config-google": "0.14.0",
"eslint-plugin-prettier": "4.0.0",
"jest": "27.5.1",
"npm-run-all": "4.1.5",
"prettier": "2.6.2",
"ts-jest": "27.1.5",
"typescript": "4.4.4",
"npm-force-resolutions": "0.0.10"
}

Module-2:
"dependencies": {
"@sap/cds": "5.9.5",
"reflect-metadata": "0.1.13",
"@sap/xb-msg-amqp-v100": "0.9.58",
"@sap-cloud-sdk/util": "2.4.0",
"winston": "3.7.2",
"@sap-cloud-sdk/connectivity": "2.4.0"
}

"devDependencies": {
"@sap/cds": "5.9.5",
"@sap/cds-dk": "6.1.1",
"@types/eslint": "8.4.2",
"@types/jest": "27.5.1",
"@types/node": "17.0.35",
"@types/prettier": "2.6.1",
"@typescript-eslint/eslint-plugin": "5.25.0",
"@typescript-eslint/parser": "5.25.0",
"cds2types": "2.7.2",
"eslint": "8.16.0",
"eslint-config-google": "0.14.0",
"eslint-plugin-prettier": "4.0.0",
"jest": "27.5.1",
"npm-run-all": "4.1.5",
"prettier": "2.6.2",
"ts-jest": "27.1.5",
"typescript": "4.4.4",
"npm-force-resolutions": "0.0.10"
}

Module-3:
"dependencies": {
"@ppbr/integration-common": "file:../packages/ppbr-integration-common",
"@ppbr/monitoring": "file:../packages/ppbr-monitoring",
"@sap-cloud-sdk/connectivity": "2.4.0",
"@sap-cloud-sdk/odata-v2": "^2.4.0",
"@sap-cloud-sdk/openapi": "2.4.0",
"@sap-cloud-sdk/util": "2.4.0",
"@sap/cds": "5.9.5",
"@sap/hana-client": "2.12.25",
"@sap/xb-msg-amqp-v100": "0.9.58",
"@sap/xsenv": "3.2.2",
"@sap/xssec": "3.2.13",
"axios": "0.24.0",
"cds-routing-handlers": "3.0.6",
"cf-nodejs-logging-support": "6.13.0",
"minimist": "1.2.6",
"passport": "0.6.0",
"reflect-metadata": "0.1.13",
"underscore": "^1.13.6",
"uuid": "8.3.2",
"winston": "3.7.2"
}

"devDependencies": {
"@sap-cloud-sdk/openapi-generator": "2.6.0",
"@sap/cds-dk": "6.1.1",
"@types/eslint": "8.4.2",
"@types/express": "4.17.13",
"@types/jest": "27.5.1",
"@types/minimist": "1.2.2",
"@types/node": "17.0.35",
"@types/passport": "1.0.7",
"@types/prettier": "2.6.1",
"@types/uuid": "8.3.4",
"@typescript-eslint/eslint-plugin": "5.25.0",
"@typescript-eslint/parser": "5.25.0",
"cds2types": "2.7.2",
"eslint": "8.16.0",
"eslint-config-google": "0.14.0",
"eslint-plugin-prettier": "4.0.0",
"jest": "^27.5.1",
"nodemon": "2.0.16",
"npm-force-resolutions": "0.0.10",
"npm-run-all": "4.1.5",
"prettier": "2.6.2",
"sqlite3": "5.0.8",
"supertest": "6.2.3",
"ts-jest": "27.1.5",
"ts-node": "10.8.0",
"typescript": "4.4.4"
}

Issue happens when upgrading @sap/cds version in all three modules to 6.6.2 and the below error occurs.

[2023-04-06T10:54:19.170Z] ERROR (integration-service): _TypeError: Cannot read properties of undefined (reading 'initial')
at Service.handle (/Users/I500210/ppbr-monorepo/backend/integrators/packages/ppbr-monitoring/node_modules/@sap/cds/lib/srv/srv-dispatch.js:57:29)
at Service.dispatch (/Users/I500210/ppbr-monorepo/backend/integrators/packages/ppbr-monitoring/node_modules/@sap/cds/lib/srv/srv-dispatch.js:42:15)
at Service.run (/Users/I500210/ppbr-monorepo/backend/integrators/packages/ppbr-monitoring/node_modules/@sap/cds/lib/srv/srv-api.js:71:17)
at IntegrationJobsRepository.runQueryOnOwnTransaction (/Users/I500210/ppbr-monorepo/backend/integrators/ppbr-job-integrator/src/integration/database/IntegrationJobsRepository.ts:54:30)
at IntegrationJobsRepository.getRunningJobOfIntegrationName (/Users/I500210/ppbr-monorepo/backend/integrators/ppbr-job-integrator/src/integration/database/IntegrationJobsRepository.ts:15:17)
at IntegrationService.isThereAJobOfSameIntegrationNameRunning (/Users/I500210/ppbr-monorepo/backend/integrators/ppbr-job-integrator/src/integration/service/IntegrationService.ts:202:39)
at IntegrationService.sync (/Users/I500210/ppbr-monorepo/backend/integrators/ppbr-job-integrator/src/integration/service/IntegrationService.ts:62:22)
at SynchronizeHandler.handle (/Users/I500210/ppbr-monorepo/backend/integrators/ppbr-job-integrator/src/integration/odata/SyncronizeHandler.ts:14:31)
at ActionMetadata.exec (/Users/I500210/ppbr-monorepo/backend/integrators/ppbr-job-integrator/node_modules/cds-routing-handlers/src/metadata/ActionMetadata.ts:238:45)
at Function. (/Users/I500210/ppbr-monorepo/backend/integrators/ppbr-job-integrator/node_modules/cds-routing-handlers/src/CDSHandler.ts:185:37)
I500210@WTWCV4Q4WR ppbr-job-integrator %

Also, besides @sap/cds library, @sap/cds-dk is also updated to 6.6.2 to make all dependencies refer the same version of CDS library but this did not help and same error occurred again.

Could you please help us in getting this issue resolved as this seems like an upgrade error in CDS itself.

Kindly do let us know if any further information is required. Many thanks in advance.

View Entire Topic
Arley
Product and Topic Expert
Product and Topic Expert
0 Kudos

This issue seems to be a regression. Please report it in our internal GitHub repository.

sridhar_thiyagarajan
Participant
0 Kudos

arley.trianamorin - Many thanks for the response. It is raised as an issue and the reference is https://github.tools.sap/cap/issues/issues/13478.