Dex code used up CPU?

Hello! I am following the moralis dex video. My code is very minimal, however my server’s CPU is at 100%. I have installed and removed the 1inch plugin a few times, is that the culprit? Here is my server URL: https://iqvaw6azff7h.usemoralis.com:2053/server How can I fix this? Here is the JS file code, thank you:

const serverUrl = "https:XYZ";
const appId = "ABC";
Moralis.start({ serverUrl, appId });

async function init(){
    await Moralis.initPlugins();
    await Moralis.enable();
    await listAvailableTokens();
}

async function listAvailableTokens(){
    const result = await Moralis.Plugins.oneInch.getSupportedTokens({
        chain: 'bsc,
      });
    const tokens = result.tokens;
    let parent = document.getElementById("token_list");
    for( const address in tokens){
        let token = tokens[address];
        let div = document.createElement("div");
        div.className = "token_row";
        let html = `
        <img class="token_list_img" src="${token.logoURI}">
        <span class="token_list_text">${token.symbol}</span>
        `
        div.innerHTML = html;
        parent.appendChild(div);
    }
}

async function login() {
  let user = Moralis.User.current();
  if (!user) {
   try {
      user = await Moralis.authenticate({ signingMessage: "Hello World!" })
      console.log(user)
      console.log(user.get('ethAddress'))
   } catch(error) {
     console.log(error)
   }
  }
}

function openModal(){
    document.getElementById("token_modal").style.display = "block";
}

function closeModal(){
    document.getElementById("token_modal").style.display = "none";
}
document.getElementById("modal_close").onclick = closeModal;
document.getElementById("from_token_select").onclick = openModal;
document.getElementById("login_button").onclick = login;

/*async function logOut() {
  await Moralis.User.logOut();
  console.log("logged out");
}*/

init();

if your server CPU is in 100%, and not your local computer CPU, then it shouldn’t be related to 1Inch plugin. maybe you added some sync event to that server, or it was 100% only for a short period of time

can you share your server subdomain/url?

1 Like

Hey thank you! Here is my server url: https://iqvaw6azff7h.usemoralis.com:2053/server

your server seems fine, it is not constantly in 100% now, it can be for short periods of time

1 Like

hi anna, the server will go back to normal after the 1inch plugin is installed. let it run for some time and it will no longer be at 100%. i had the same issue, after awhile it went back down.

1 Like