sasjs / server

Build Apps on Base SAS

Home Page:https://server.sasjs.io

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

JS Stored Program calling SASjsApi issue

medjedovicm opened this issue ยท comments

In the JS STP running HTTP request makes server freeze.

So basically node child_process tries to run request to initial parent node process.
There is only one clue in the log, request is being made by: editor.worker.js

GET /editor.worker.js HTTP/1.1" 200 201849

Steps to reproduce:

  1. We need axios available
    In:
    /api/src/controllers/internal/createJSProgram.ts

image

  1. Code
axios('http://localhost:5000/SASjsApi/info').then(res => console.log(res.data))

#329
fixed the issue of server freeze.

In the JS STP running HTTP request makes server freeze.

So basically node child_process tries to run request to initial parent node process. There is only one clue in the log, request is being made by: editor.worker.js

GET /editor.worker.js HTTP/1.1" 200 201849

Steps to reproduce:

  1. We need axios available
    In:
    /api/src/controllers/internal/createJSProgram.ts

image

  1. Code
axios('http://localhost:5000/SASjsApi/info').then(res => console.log(res.data))

adding axios to requiredModules string would not work as it is a third-party library. You need to provide bundled code if you want to use axios. Rather, I would suggest to use node's built-in module like 'httporhttps`

here's the reference for using http module

const http = require('http');

http.get('http://localhost:5000/SASjsApi/info', res => {
  let data = [];
  const headerDate = res.headers && res.headers.date ? res.headers.date : 'no response date';
  console.log('Status Code:', res.statusCode);
  console.log('Date in Response header:', headerDate);

  res.on('data', chunk => {
    data.push(chunk);
  });

  res.on('end', () => {
    console.log('Response ended: ');
    const responseData = JSON.parse(Buffer.concat(data).toString());
    console.log('Response Data: ', responseData);
  });
}).on('error', err => {
  console.log('Error: ', err.message);
});

๐ŸŽ‰ This issue has been resolved in version 0.28.2 ๐ŸŽ‰

The release is available on:

Your semantic-release bot ๐Ÿ“ฆ๐Ÿš€