cloud-sdk-js: Failed to fetch instance destinations. (Timed out after 10000ms)
Description of erroneous behaviour
We have a Node.js CAP application edom-retailer-core. In MDIClient.js, we are making a request via destination connecting to MdiDestination
.
// package.json
"MdiDestination": {
"kind": "rest",
"credentials": {
"destination": "mdi-dest",
"requestTimeout": 1000000
The API in the destination retrieves 2000 items at a time and if it has more data, it will provide a deltaToken
that we use to make the same call but with the deltaToken
to retrieve the next 2000 items. We repeat this till all the items are retrieved. Currently our API has 19000+ items.
// MDIClient.js
const MDIDest = await cds.connect.to('MdiDestination');
const logRequest = new cds.Request();
const baseQuery = `GET /log/sap.odm.businesspartner.BusinessPartner`;
let moreData = true;
while (moreData) {
if (deltaToken !== false) {
logRequest.query = `${baseQuery}?since=${deltaToken}`;
}
const response = await MDIDest.tx(logRequest).run(logRequest.query);
...
if (!response.hasMoreEvents) {
moreData = false;
}
}
The request is successful for the first 6-9 iterations but throws an error afterwards:
Error: Timed out after 10000ms
at buildError (/mnt/c/Users/C5315270/Desktop/projects/edom-retailer-core/node_modules/opossum/lib/circuit.js:710:17)
at Timeout.<anonymous> (/mnt/c/Users/C5315270/Desktop/projects/edom-retailer-core/node_modules/opossum/lib/circuit.js:511:29)
at listOnTimeout (internal/timers.js:554:17)
at processTimers (internal/timers.js:497:7) {
cause: ErrorWithCause: Failed to fetch instance destinations.
at new ErrorWithCause (/mnt/c/Users/C5315270/Desktop/projects/edom-retailer-core/node_modules/@sap-cloud-sdk/util/dist/error-with-cause.js:31:16)
at /mnt/c/Users/C5315270/Desktop/projects/edom-retailer-core/node_modules/@sap-cloud-sdk/core/dist/connectivity/scp-cf/destination/destination-service.js:116:27
at runNextTicks (internal/process/task_queues.js:62:5)
at listOnTimeout (internal/timers.js:523:9)
at processTimers (internal/timers.js:497:7)
at async Promise.all (index 0)
I attached the console log and console error below. log.txt error.txt
Detailed steps to reproduce
For example (→ replace by appropriate ones for your case):
- git clone https://github.wdf.sap.corp/c4u/edom-retailer-core.git
- git checkout feat/25-mdiclient-outbound
- npm install
- cds deploy
- cds run
- In Postman, make a GET request to http://localhost:4004/api/alpha/mdiclient/MDIClient
Details about your project
edom-retailer | https://github.wdf.sap.corp/c4u/c4u-cn-edom-retailer |
---|---|
CAP Java Runtime | version |
OData Version | version |
@sap/cds-compiler | 2.1.6 |
@sap/cds-dk | 4.0.7 |
Used Versions:
- node version via
node -v
: v12.22.1 - npm version via
npm -v
: 6.14.12 - SAP Cloud SDK version you used as dependency
- “@sap-cloud-sdk/core”: “^1.41.0”,
About this issue
- Original URL
- State: closed
- Created 3 years ago
- Comments: 25 (14 by maintainers)
I’m able to connect to the consumer subaccount by providing a userJwt. Thank you!
await cloudSDK.getDestination('mdi-dest',{ useCache: true, isolationStrategy: "Tenant", userJwt:jwt})
Hey @LaxOn,
btw, you can enable the SDK caching if you transform this line:
const dest = await cloudSDK.getDestination('mdi-dest');
to this:const dest = await cloudSDK.getDestination('mdi-dest', { useCache: true });