SAP / cloud-sdk-js

Use the SAP Cloud SDK for JavaScript / TypeScript to reduce development effort when building applications on SAP Business Technology Platform that communicate with SAP solutions and services such as SAP S/4HANA Cloud, SAP SuccessFactors, and many others.
Apache License 2.0
162 stars 56 forks source link

Endpoint being hit multiple times from Node js application deployed to Cloud foundry #4947

Closed AccNamrata closed 4 weeks ago

AccNamrata commented 1 month ago

Issue also raised on Stack Overflow - https://stackoverflow.com/questions/78923295/sdk-library-sap-cloud-sdk-http-client

Describe the bug We have deployed nodeJS application (microservice) to Cloud Foundry in Canada (ca10) region. This application internally calls https REST endpoint in Convergent mediation system(On premise)

we are using Cloud SDk library ->@sap-cloud-sdk/http-client - npm (npmjs.com) and it function executeHttpRequest to send request to convergent mediation system(On premise ) via cloud connector .The connectivity is made using Destination which is mainatained in BTP subaccount.

When we send request to Microservice on particular endpoint. Cloud connector logs shows three requests being fired at the same time even though we send the request once.

To Reproduce Steps to reproduce the behavior: NA

Expected behavior A clear and concise description of what you expected to happen.

Screenshots Logs from Cloud connector showing 3 requests for every request being sent by BTP microservice If applicable, add screenshots to help explain your problem.

image

Used Versions:

Code Examples

const { executeHttpRequest } = require('@sap-cloud-sdk/http-client');
   const express = require('express'); const app = express();
   app.use(express.json());

   app.post('/xyz', async (req, res) => {
       try {
           async function callPostApi(req, destination) {
               const response = await executeHttpRequest(
                   {
                       destinationName: destination,
                   },
                   {
                       method: 'POST',
                       url: req.url,
                       data: req.body,
                       maxContentLength: Infinity,
                       maxBodyLength: Infinity,
                       headers: {
                           "Content-Type": "application/json"
                       },
                   }
               );
               return response.data;
           }
           const responseData = await callPostApi(req, "Destination Name");
           res.status(200).send(responseData);

       } catch (error) {
           console.error('Error:', error);
           res.status(500).send({ message: "An error occurred", error });
       } });

Log file If applicable, add your log file or related error message. Again, please remove your sensitive information.

Impact / Priority High Impact We are going live with our microservice deployed on BTP this April 2025. Currently we are in SIT execution phase, and this impacts our System Integration test. Timeline: e.g. Go-Live is in April 2025

tomfrenken commented 4 weeks ago

Duplicate of https://github.com/SAP/cloud-sdk-js/issues/4949