I ve created my own API using cloud shell with editor of Google app engine. Here is the snippet of the code which is working fine in testing:
app.get('/fetch_ticker', (req, res) => {
(async() => {
let pair = req.param('pair', "BTC/ETH");
let ex = req.param('exchange', "coinmarketcap");
let myArr = [];
let exchange = await new ccxt[ex]();
let tickers = await exchange.fetchTicker(pair);
myArr.push(tickers);
//Send req
res.status(200).send(myArr);
})()
});
Now, when I try it after 'Gcloud app deploy' and run it in production, other get requests are working fine but when 'ex' is equal to 'coinmarketcap', it just constantly loading and in the end gives 500 error.
Update:
Here is the log:
2018-11-03 11:43:50 default[20181103t163752] ==== JS stack trace =========================================
2018-11-03 11:43:50 default[20181103t163752]
2018-11-03 11:43:50 default[20181103t163752] Security context: 0x3e6826325879 <JSObject>
2018-11-03 11:43:50 default[20181103t163752] 1: indexBy(aka indexBy) [/srv/node_modules/ccxt/js/base/functions/generic.js:~82] [pc=0x30a50d2a5374](this=0x32f
9351022d1 <undefined>,/* anonymous */=0x1e7ccf12dc59 <JSArray[37746]>,/* anonymous */=0x32f935144e51 <String[2]: id>,/* anonymous */=0x32f9351022d1 <undefined>)
2018-11-03 11:43:50 default[20181103t163752] 2: arguments adaptor frame: 2->3
2018-11-03 11:43:50 default[20181103t163752] 3: set_markets(aka setMarkets) [/srv/node_modules/ccxt/js/base/Exchange.js:613] ...
2018-11-03 11:43:50 default[20181103t163752]
2018-11-03 11:43:50 default[20181103t163752] FATAL ERROR: CALL_AND_RETRY_LAST Allocation failed - JavaScript heap out of memory
2018-11-03 11:43:50 default[20181103t163752] 1: node::Abort() [node]
I've tried to increase the memory using node --max_old_space_size=4096 app.js but the error still remains.