SMI from custom installation page not working on local testing

Hey, guys!

I have an app that has a custom installation page (Freshchat).
From this page, I invoke a method from server (SMI).
It always worked on production as well running locally.
But recently I noticed that it does not work locally anymore.
When I invoke the method, I get an error:

{message: “Something went wrong”}

But in production still works.

So I created a new app, pretty simple, just to test it, and in fact this error is happening.

FDK Version:
6.9.6
Node:
10.18.1

Code:

server.js

exports = {
  signin: function (options) {
    console.log("I was here");
    renderData(undefined, "ok");
  },
};

iparams.html

<html>
  <head>
    <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.2.0/jquery.min.js"></script>
    <script src="https://static.freshdev.io/fdk/2.0/assets/fresh_client.js"></script>
    <link rel="stylesheet" type="text/css" href="https://static.freshdev.io/fdk/2.0/assets/freshchat.css" />
    <link rel="stylesheet" type="text/css" href="./assets/style.css" />
  </head>
  <body>
    <button id="btn-login">Login</button>
  </body>

  <script>
    var client;
    $(document).ready(function () {
      app.initialized().then(function (_client) {
        client = _client;

        $("#btn-login").on("click", function () {
          client.request.invoke("signin", { body: { test: "test" } }).then(
            function (data) {
              console.log(data);
            },
            function (error) {
              console.log(error);
            }
          );
        });
      });
    });
    function getConfigs(savedConfigs) {}

    function postConfigs() {}
  </script>
</html>

No server output!

Frontend output clicking on button:

{message: “Something went wrong”}

@samuelpares

I took the code and created the sample app to verify the same. Looks like it is working as expected,

❯ fdk run
Starting local testing server at http://*:10001/    
Append 'dev=true' to your Freshchat account URL to start testing    
e.g. https://web.freshchat.com/a/230117337757345/inbox/3/0/conversation/233020826993979?dev=true    
Quit the server with Control-C.

To simulate product, app setup, and external events, visit - http://localhost:10001/web/test
To test the installation page, visit - http://localhost:10001/custom_configs
I was here // Console logged!

As per the log on the iparams.html page in browser console,

form:21 {requestID: "784d5219-3d85-41ed-9a55-9eb68090beb3", response: "ok"}
requestID: "784d5219-3d85-41ed-9a55-9eb68090beb3"response: "ok"
__proto__: Object

Do you mind sharing some of the following things while to reproduce this issue again?

  1. NODE DEBUG logs to see if something unusual happening with CLI (fdk)
  2. HAR File to see if something is wrong on the browser’s end.
3 Likes

@Saif, looking at your answer I realized that I forgot to mention that I’m testing it on the account. I mean, I’m using the end-to-end test, I guess this is the name of this feature… I call fdk run, and then I can install through the account:

If I test it on http://localhost:10001/custom_configs, it works fine!
But here’s the info you asked:

Node logs:

FDK 1484: (data-util.js) Read {"teste3_101_101_freshchat":{"teste3_101_101_custom_iparams":{}}}
FDK 1484: (data-util.js) Read {"teste3_101_101_freshchat":{"teste3_101_101_custom_iparams":{}}}
FDK 1484: (data-util.js) Read {"teste3_101_101_freshchat":{"teste3_101_101_custom_iparams":{}}}
FDK 1484: (data-util.js) Read {"teste3_101_101_freshchat":{"teste3_101_101_custom_iparams":{}}}
FDK 1484: (app.js) /app/-1 responding with {"extDetail":{"extension_id":-1,"id":-1,"name":"teste3","display_name":"teste3","features":["db","backend"],"cover_art":{"thumb":"http://localhost:10001/web/assets/freshworks_logo.svg","thumb2x":"http://localhost:10001/web/assets/freshworks_logo.svg"},"screenshots":[{"large":"https://dej20ntrln9u1.cloudfront.net/images/test_data/791/live_screenshot/large/Screen_Shot_2018_01_24_at_11.03.20_PM.png","large2x":"https://dej20ntrln9u1.cloudfront.net/images/test_data/791/live_screenshot/large2x/Screen_Shot_2018_01_24_at_11.03.20_PM.png"}],"categories":[],"type":6,"install_count":0,"published_at":"Mon Feb 08 2021 19:38:28 GMT-0300 (Brasilia Standard Time)","contact_details":{"support_email":"dummy@heeloc.com","support_url":"http://com.com"},"options":{},"is_local":true,"has_config":true,"configs_url":"http://localhost:10001/custom_configs/form","published_date":"a few moments","platform_details":{"2.0":true},"version_id":-1,"events":{},"placeholders":{"ticket_sidebar":{"url":"https://dej20ntrln9u1.cloudfront.net/app-assets/test_data/e23f49923ae1f1191bcd/app/template.html","icon_url":"https://dej20ntrln9u1.cloudfront.net/app-assets/test_data/e23f49923ae1f1191bcd/app/icon.svg"}},"app_type":1},"installedExtn":{"installed_extension_id":-1,"installed_versions":[-1],"extension_id":-1,"version_id":-1,"installed":false,"enabled":false,"configs":{},"state":2,"extension_type":6}}
FDK 1484: (data-pipe.js) received call for route "smi" with action "invoke" and body {"action":"invoke","methodName":"signin","methodParams":{"body":{"test":"test"}},"data":{"isInstall":true},"isInstall":true}
FDK 1484: (data-util.js) Read {"teste3_101_101_freshchat":{"teste3_101_101_custom_iparams":{}}}
FDK 1484: (error.js) uncaught exception while handling web request "TypeError [ERR_INVALID_ARG_TYPE]: The first argument must be one of type string, Buffer, ArrayBuffer, Array, or Array-like Object. Received type undefined
    at Function.from (buffer.js:207:11)
    at getJWTPayload (/home/samuel/.nvm/versions/node/v10.18.1/lib/node_modules/fdk/lib/utils/config-util.js:143:26)
    at Object.isAllowedIssuerRoute (/home/samuel/.nvm/versions/node/v10.18.1/lib/node_modules/fdk/lib/utils/config-util.js:158:20)
    at dpRouterExec (/home/samuel/.nvm/versions/node/v10.18.1/lib/node_modules/fdk/lib/routes/data-pipe.js:32:21)
    at asyncify (/home/samuel/.nvm/versions/node/v10.18.1/lib/node_modules/fdk/lib/utils/helper-util.js:157:28)
    at Layer.handle [as handle_request] (/home/samuel/.nvm/versions/node/v10.18.1/lib/node_modules/fdk/node_modules/express/lib/router/layer.js:95:5)
    at next (/home/samuel/.nvm/versions/node/v10.18.1/lib/node_modules/fdk/node_modules/express/lib/router/route.js:137:13)
    at Route.dispatch (/home/samuel/.nvm/versions/node/v10.18.1/lib/node_modules/fdk/node_modules/express/lib/router/route.js:112:3)
    at Layer.handle [as handle_request] (/home/samuel/.nvm/versions/node/v10.18.1/lib/node_modules/fdk/node_modules/express/lib/router/layer.js:95:5)
    at /home/samuel/.nvm/versions/node/v10.18.1/lib/node_modules/fdk/node_modules/express/lib/router/index.js:281:22
    at Function.process_params (/home/samuel/.nvm/versions/node/v10.18.1/lib/node_modules/fdk/node_modules/express/lib/router/index.js:335:12)
    at next (/home/samuel/.nvm/versions/node/v10.18.1/lib/node_modules/fdk/node_modules/express/lib/router/index.js:275:10)
    at /home/samuel/.nvm/versions/node/v10.18.1/lib/node_modules/fdk/lib/middlewares/validator.js:16:32
    at asyncify (/home/samuel/.nvm/versions/node/v10.18.1/lib/node_modules/fdk/lib/utils/helper-util.js:157:28)
    at dpRouter.use (/home/samuel/.nvm/versions/node/v10.18.1/lib/node_modules/fdk/lib/routes/data-pipe.js:52:82)
    at Layer.handle [as handle_request] (/home/samuel/.nvm/versions/node/v10.18.1/lib/node_modules/fdk/node_modules/express/lib/router/layer.js:95:5)"

loupentest-chat.freshchat.com.har (543.8 KB)

2 Likes

@samuelpares

I was able to successfully reproduce the issue. Thank you so much for reporting it. I am logging this as a bug with engineering team as the local simulation of the app is different to production varient.

3 Likes

Hello!
Is there any news?
Building an app for Freshdesk now, and on current version (6.10.0), it is still happening.
Huge setback for testing the app with this issue.

3 Likes

Hi @samuelpares,

We have about it up internally with the team. However, we will follow up again.

cc: @harish.janjam

1 Like

Hey @Saif, is there any news? I am having this too at 7.0.1.
I am making a FreshCaller app with just one action, but that also errors out with:
jquery.min.js:4 POST http://localhost:10001/dprouter 404 (Not Found)

I just peeked into the engineering ticket on this topic. Unfortunately, no update. I hope the platform team will pick this up, given that some of the most requested features have gone live with the v7.0.1 release.

As a workaround, is it possible to use a configuration page to open up and test SMI alone?

I have found that I didn’t put the (correct) functionname in actions.js. That seemed to be the problem. I would have wanted FDK to give me a more precise error message.

1 Like