Closed mihaileb closed 1 year ago
I've not been able to recreate your error. I put the same code into a test only adapting for local testing and it runs fine. As long as the credentials are loaded by the @sap/xsenv module, it doesn't seem to matter where they came from. The UPS loads fine. Make sure that the credentials you are loading in the UPS are valid. Maybe you need more error handling in there to catch some underlying issue in your configuration. That's one of the few changes to your code I made when testing - I surrounded it with a try catch block. https://github.com/SAP-samples/hana-hdbext-promisfied-example/blob/c52270e68e4fdf83a378a162731f4a9ac5ecd9b6/hdb/test.js#L123
Actually, I found the error. It only occurred in the CommonJS version of the module and not in the ES6 version. It was a scoping issue when accessing this
within the promise callback. It didn't really have anything to do with the UPS at all. I pushed a new version to NPM. All the tests in the CommonJS version now pass as well.
Thank you Thomas! We will use the newest version :)
Hello Thomas, Unfortunatly it seams that we cannot use createConnection(options) method:
This statement throws an error:
2023-09-10T13:55:17.308+0000 [APP/PROC/WEB/0] STDERR TypeError: Cannot read properties of undefined (reading 'setSchema')
2023-09-10T13:55:17.308+0000 [APP/PROC/WEB/0] STDERR at /home/vcap/app/node_modules/sap-hdb-promisfied/index.cjs:86:28
2023-09-10T13:55:17.308+0000 [APP/PROC/WEB/0] STDERR at done (/home/vcap/app/node_modules/sap-hdb-promisfied/node_modules/hdb/lib/Client.js:163:7)
2023-09-10T13:55:17.308+0000 [APP/PROC/WEB/0] STDERR at connReceive (/home/vcap/app/node_modules/sap-hdb-promisfied/node_modules/hdb/lib/protocol/Connection.js:464:5)
2023-09-10T13:55:17.308+0000 [APP/PROC/WEB/0] STDERR at Connection.receive (/home/vcap/app/node_modules/sap-hdb-promisfied/node_modules/hdb/lib/protocol/Connection.js:390:3)
2023-09-10T13:55:17.308+0000 [APP/PROC/WEB/0] STDERR at TLSSocket.ondata (/home/vcap/app/node_modules/sap-hdb-promisfied/node_modules/hdb/lib/protocol/Connection.js:243:12)
2023-09-10T13:55:17.308+0000 [APP/PROC/WEB/0] STDERR at TLSSocket.emit (node:events:513:28)
2023-09-10T13:55:17.308+0000 [APP/PROC/WEB/0] STDERR at addChunk (node:internal/streams/readable:324:12)
2023-09-10T13:55:17.308+0000 [APP/PROC/WEB/0] STDERR at readableAddChunk (node:internal/streams/readable:297:9)
2023-09-10T13:55:17.308+0000 [APP/PROC/WEB/0] STDERR at Readable.push (node:internal/streams/readable:234:10)
2023-09-10T13:55:17.308+0000 [APP/PROC/WEB/0] STDERR at TLSWrap.onStreamRead (node:internal/stream_base_commons:190:23)
I have attached the env variable which states that we have a cups with the credentials of HANA from another region:
I cannot attach a picture but I will attach the env file from BTP with some of the information removed:
{ "VCAP_SERVICES": { "user-provided": [ { "label": "user-provided", "name": "SERVICE_INSTANCE_EU10", "tags": [], "instance_guid": "9bc228d9-f711-4071-9246-59ad2d5a5977", "instance_name": "SERVICE_INSTANCE_EU10", "binding_guid": "b3af1442-a42f-417b-8133-9cc7aa37cd7f", "binding_name": null, "credentials": { "certificate": "-----BEGIN CERTIFICATE-----\XXXXXEND CERTIFICATE-----", "database_id": "b84d490c-261f-4e51-a11d-d0faea0f3255", "driver": "com.sap.db.jdbc.Driver", "hdi_password": "XXXXX", "hdi_user": "XXXXX", "host": "XXXXX.hna0.prod-eu20.hanacloud.ondemand.com", "password": "XXXXX", "port": "443", "schema": "XXXXX", "url": "jdbc:sap://b84d490c-261f-4e51-a11d-d0faea0f3255.hna0.prod-eu20.hanacloud.ondemand.com:443?encrypt=true&validateCertificate=true¤tschema=9CCB4CCC1F7B46E4B7D8296A2F83D367", "user": "XXXXX" }, "syslog_drain_url": null, "volume_mounts": [] } ] } }
Using the comment out method works fine when in the correct region and an HDI, but our case is using a cups for a HANA in another region. This is critical for the customer. Can you please advice, THank you, Bruno.