cap-js / cds-dbs

Monorepo for SQL Database Services for CAP
https://cap.cloud.sap/docs/
Apache License 2.0
32 stars 9 forks source link

postgres in hybrid profile #476

Open lucasborin opened 4 months ago

lucasborin commented 4 months ago

Description of erroneous behaviour

The statement cds watch --profile hybrid binds the Postgres instance, but the CAP read fails due to resource timeout.

CAP database call:

const entries = await cds.db.run(`SELECT * FROM ... LIMIT 10`)

Console (sensitive data hidden):

[odata] - POST /odata/v4/...
[cds] - TimeoutError: ResourceRequest timed out
    at ResourceRequest._fireTimeout (/home/.../node_modules/generic-pool/lib/ResourceRequest.js:62:17)
    at Timeout.bound (/home/.../node_modules/generic-pool/lib/ResourceRequest.js:8:15)
    at listOnTimeout (node:internal/timers:569:17)
    at process.processTimers (node:internal/timers:512:7)

Project .cdsrc.json:

{
    "requires": {
        "destinations": true,
        "db": {
            "kind": "postgres",
            "dialect": "postgres",
            "impl": "@cap-js/postgres"
        },
        "auth": {
            "kind": "xsuaa",
            "restrict_all_services": false
        }
}

Project .cdsrc-private.json (sensitive data hidden):

{
  "requires": {
    "[hybrid]": {
      "destinations": {
        "binding": {
          "type": "cf",
          "apiEndpoint": "...",
          "org": "...",
          "space": "...",
          "instance": "...",
          "key": "...",
          "resolved": false
        },
        "kind": "destinations",
        "vcap": {
          "name": "destinations"
        }
      },
      "db": {
        "binding": {
          "type": "cf",
          "apiEndpoint": "...",
          "org": "...",
          "space": "...",
          "instance": "...",
          "key": "...",
          "resolved": false
        },
        "kind": "postgres",
        "vcap": {
          "name": "db"
        }
      },
      "auth": {
        "binding": {
          "type": "cf",
          "apiEndpoint": "...",
          "org": "...",
          "space": "...",
          "instance": "...",
          "key": "...",
          "resolved": false
        },
        "kind": "xsuaa",
        "vcap": {
          "name": "auth"
        }
      }
    }
  }
}

Details about your project

Interal Ask i840577
Node.js v18.19.0
@sap/cds 7.3.1
@sap/cds-compiler 4.3.2
@sap/cds-dk 7.3.2
@sap/cds-dk (global) 7.6.1
@sap/eslint-plugin-cds 2.6.3
@sap/cds-mtxs 1.12.1
@cap-js/cds-types 0.2.0
vobu commented 4 months ago

hm, I did the same thing, but on Azure: https://github.com/Azure-Samples/app-service-javascript-sap-cap-quickstart/blob/293b5a4d78c3ccd2ca38440b0b01a19c2ae6f517/src/.cdsrc.json#L26 that worked ootb. → assumption: this might be an issue with CF/destination?

patricebender commented 2 months ago

@lucasborin have you been able to solve this problem on your end?

lucasborin commented 2 months ago

@lucasborin have you been able to solve this problem on your end?

I'm using SAP HANA now, and I was not able to use the postgres in hybrid mode.