JavaScript For, functions and mixed return

Im creating my own version of a MarkDown render. My goal is to read a string or file line by line then return the MD rendered as HTML. The problem im facing is my return and line by line functionaility is not-returning what I want and I dont know why. Ive tried debugging but everything seemed fine. Ive also tried chaning my for loop but still no luck.

//function used to render MD for the user

function render(md){
    let code = ""; //For functions return

    let mdLines = md.split('n');

    for(let i = 0; i < mdLines.length; i++){

        //Statements to see what kind of MD header a line is.
        //I only have these statments as I just started this and am still figuring how I want to approach.

        if(mdLines[i].slice(0, 1) == "#"){
           code += code.concat("<h1>" + mdLines[i].replace("#", "") + "</h1>")
        }

        if(mdLines[i].slice(0, 2) == "##"){
           code += code.concat("<h2>" + mdLines[i].replace("##", "") + "</h2>")
        }

        if(mdLines[i].slice(0, 3) == "###"){
           code += code.concat("<h3>" + mdLines[i].replace("###", "") + "</h3>")
        }

        if(mdLines[i].slice(0, 4) == "####"){
           code += code.concat("<h4>" + mdLines[i].replace("#", "") + "</h4>")
        }

        if(mdLines[i].slice(0, 5) == "#####"){
           code += code.concat("<h5>" + mdLines[i].replace("#", "") + "</h5>")
        }

        if(mdLines[i].slice(0, 6) == "######"){
           code += code.concat("<h6>" + mdLines[i].replace("######", "") + "</h6>")
        }
    };
    
    return code;
}


//editor
//This is what the users .js file would be.
//I have it set up like this for testing.

let text1 = "## he#llo n there n # yooo"
let text2 = "# he#llo n there n ## yooo"

console.log(render(text1));
console.log(render(text2));

text1 returns <h1># he#llo </h1><h1># he#llo </h1><h2> he#llo </h2>
text2 reutrns <h1> he#llo </h1>

text1 should return <h2>he#llo</h2> there <h1> yooo </h1>
text2 should return <h1> he#llo </h1> there <h2> yooo </h2>

If someone could help me get the proper returns and some potentially reusable code for this issue it would be greatly appreciated.

Ive also looked up the issue with some select terms but it seems no one has documented my very specific issue.

Also for those saying it’s a beginner issue just use Elseif, I did that. It dont work. Soooooo….. womp womp.

Using uBlock to hide a parent element that includes a child element that contains a specific string

I’m a member of a forum community where the site owner has set up Akismet as an alternative to a human moderator and then he, the owner, stopped paying attention. Akismet seems to do well with the bots but a couple of human spammers have slipped through and are spamming their links to unrelated products in the forum. The community is frustrated.

The forums are set up as UL elements, with each authored post listed as LIs. Each LI has a few DIVs to display various metadata, including a DIV with an anchor for each author’s profile. Roughly, it looks like this…

<div>
<ul>
<li id="[random-id1]">Good Post</li>
<li id="[random-id2]">
<div>
<a class="title" href="spam-post.html">Spam Post Title</a>
</div>
<div id="bad-post-meta">
<a href="member.php/12345-naughtyspammer" class="username" title="Started by NaughtySpammer on Yesterday 05:41 AM">NaughtySpammer</a>
</div>
</li>
<li id="[random-id3]">Good Post</li>
</ul>
</div>

I have used uBlock to remove elements before, but nothing this complex. I’d like for uBlock to search through the a.username elements for known blacklisted spam names and hide their respective LI ancestor element.

How do I hide the offending LI? I suspect that I am missing something simple! The equivalent of display:none; is preferred.

ABP’s library of Snippets has a hide-if-contains snippet that looks like it might work but ABP’s Snippets appears to be one of the EasyList features that uBlock doesn’t support. I can’t find a uBlock equivalent to hide-if-contains, which might look like this (if I’m understanding it correctly):

forumsite.com#$#hide-if-contains naughtyspammer li

uBlock says that the #$# syntax is invalid.

Error received when sending message across JS files: Unchecked runtime.lastError: Could not establish connection. Receiving end does not exist [duplicate]

I am trying to create a Google Chrome extension web scraper, and the idea is a user clicks on the icon and the extension scrapes the current active tab and prints some processed data onto a popup.

To do this, I decided to set in my manifest a default popup.html, and have the popup.js sendMessage to a content.js file, which contains the function that scrapes the webpage. However, during my implementation, I received the following error on popup.html:0 -> Unchecked runtime.lastError: Could not establish connection. Receiving end does not exist.

I tried looking up my exact issue online, and I found an already existing stack overflow page: Chrome Extension message passing: Unchecked runtime.lastError: Could not establish connection. Receiving end does not exist

However, I tried implementing this and the error still persists. I’ve attached my manifest.JSON, popup.html, popup.js, content.js, and background.js files below:

Manifest.JSON

{
    "manifest_version": 3,
    "name": "HTML Scraper",
    "version": "1.0",
    "description": "Scrapes the HTML of the current webpage and prints it to console.",
    "permissions": ["storage", "activeTab", "scripting"],
    "background": {
      "service_worker": "background.js",
      "type": "module"
    },
    "action": {
      "default_popup": "popup.html",
      "default_icon": "icons/icon16.png"
    },
    "icons": {
      "16": "icons/icon16.png",
      "48": "icons/icon48.png",
      "128": "icons/icon128.png"
    }
  }  

popup.html

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Popup</title>
    <!-- Include popup.js -->
    <script src="popup.js"></script>
</head>
<body>
    <h1>Hi!</h1>
</body>
</html>

popup.js

if (document.readyState != 'loading') {
    chrome.tabs.query({active: true, currentWindow: true}, function(tabs) {
        chrome.tabs.sendMessage(tabs[0].id, {action: 'scrapeHTML'}, function(response) {
            console.log('Scrape command sent to content script');
        });
    });
} else {
    document.addEventListener('DOMContentLoaded', function() {
        chrome.tabs.query({active: true, currentWindow: true}, function(tabs) {
            chrome.tabs.sendMessage(tabs[0].id, {action: 'scrapeHTML'}, function(response) {
                console.log('Scrape command sent to content script');
            });
            console.log("tester");
        });
    });
}

content.js

function ScrapeHTML() {
    const htmlcontent = document.body.innerText;

    const url = document.location.href;
    
    const containsAmazon = url.includes("amazon.com/");

    chrome.runtime.sendMessage({action: 'sentLoad'},{
        html: htmlcontent,
        containsAmazon: containsAmazon
    });
}

document.addEventListener('DOMContentLoaded', function() {
    chrome.runtime.onMessage.addListener(function(message, sender, sendResponse) {
        if (message.action == 'scrapeHTML') {
            ScrapeHTML();
        } else {
            console.log('Unknown message received from popup script:', message);
        }
    });
});

background.js

// background.js
import {amazonMessage} from './helpers.js';

  chrome.runtime.onMessage.addListener((message) => {
    if (message.action === 'sentLoad') {
        const containsAmazon = message.containsAmazon;
        const text = message.html;

        if (containsAmazon) {
            console.log(amazonMessage(text, "Sponsored", "Products related to this item"));
        } else {
            console.log(text);
        }

        chrome.storage.local.set({counter: text}, function() {
            console.log("Message saved to local storage.");
        });
    }
});

I need help fixing this

I am creating a web game for a future idea project, and I’m creating sample files to copy and paste into the actual files. Well, I wrote my code for a background music on load thing but no sound. Can you help me…

I was trying to input a onload function on the body element right. Then I put all my features a things then I put this:

var menu;
function startMenuMusic() {
  menu = new sound("https://youtu.be/Dxvej27d8N0?si=N73Z76jc6kiDKNLj");
  menu.play();
}
function sound(src) {
  this.sound = document.createElement("audio");
  this.sound.src = src;
  this.sound.setAttribute("preload", "auto");
  this.sound.setAttribute("controls", "none");
  this.sound.style.display = "none";
  document.body.appendChild(this.sound);
  this.play = function () {
    this.sound.play();
  };
  this.stop = function () {
    this.sound.pause();
  };
}

but no gives it has no sound…

Ready to code full websites design and flows

I am new to NextJS 14. I’ve been using it for a mounth now but i want to practice more but i don’t want to design the website myself, so I’m wondering if there are any websites that provide ready to code full websites design and flows so i can practice on the coding part without having to make the design on my own.

I actually tried the websites that provide challenges but the challenges have designs for only one page (Landing page, Login page …).
The only website that i found is mobbin but it’s paid is any other free alternatives?

Error (Status of 500) and X-Frame-Options with google apps script redirect function

I am currently trying to build a web app with google apps script, and I have implemented a login function.
The login happens as it should, but I then try to redirect the user to the dashboard of my web app. The current code for the dashboard is the basic code for a new HTML file within apps script with a h1 title, so there are no issues with it.

In my login.html file, this is how it should redirect the user to the dashboard page:

function onLoginSuccess(sessionId) {
      if (sessionId) {
        console.log('Success')
        console.log(sessionId)
        window.location.href = "dashboard?sessionId=" + sessionId;
        console.log('Success')
      } else {
        alert("Invalid email or password. Please try again.");
      }
    }

I have tried an url with "dashboard.html?sessionId=" +sessionId and I get the following error in the F12 console: Failed to load resource: the server responded with a status of 500 ()
I then tried an url without the html "dashboard?sessionId=" +sessionId and I now get the following error: Refused to display 'https://developers.google.com/' in a frame because it set 'X-Frame-Options' to 'sameorigin'.
I then tried adding .setXFrameOptionsMode(HtmlService.XFrameOptionsMode.ALLOWALL); with my return HtmlService line, but I still get the error.

With both URLs, both success and the session ID get called into the console.

Is there a way to fix the issue? Maybe another way to redirect the user, or just a way to fix the error?

Is there anybody who can help me in node.js authentication? [closed]

My problem is that, after successful login, the session is being created successfully, but redirect is not working. Why? <br>

[route](https://i.stack.imgur.com/4Skqa.png)<br>

[form html](https://i.stack.imgur.com/U6prc.png)

[authenticationcontrol](https://i.stack.imgur.com/gTLvk.png)

[login_function](https://i.stack.imgur.com/uiDK6.png)

[core.js](https://i.stack.imgur.com/u8Sec.png)

I need your help, thank you.<br>I’ve tried make some changes in login function and core.js for arrangement, but it didn’t work

Sigma.JS custom rendering

I’m trying to visualize the data coming through the API with Sigma.JS, but I can’t always get results. When I tried to visualize the dynamic incoming data without mock data by writing a simple API with Flask, it worked, but this data is slightly different from the real json data of the project, I can’t integrate the new incoming data, although I took custom rendering as an example, I couldn’t solve it. I will be leaving the json data I will be using below. In the nodes section, the json data is divided into two groups according to the y index in the form of attacker and destination, think of them as SIEM logs. ip is available in the id section, attackType in the label section

<!doctype html>
<html lang="en">
<head>
  <meta charset="UTF-8" />
  <meta name="viewport" content="width=device-width, initial-scale=1">
  <title>Sigma.js Example</title>
  <script src="https://cdnjs.cloudflare.com/ajax/libs/sigma.js/2.4.0/sigma.min.js"></script>
  <script src="https://cdnjs.cloudflare.com/ajax/libs/graphology/0.25.4/graphology.umd.min.js"></script>
  <style>
    #container {
      width: 100%;
      height: 100vh;
      background: white;
    }
  </style>
</head>
<body>
  <div id="container"></div>
  <script>
    const graph = new graphology.Graph();

    function shuffleArray(array) {
      for (let i = array.length - 1; i > 0; i--) {
        const j = Math.floor(Math.random() * (i + 1));
        [array[i], array[j]] = [array[j], array[i]];
      }
    }

    async function fetchAttackTypes() {
      try {
        const response = await fetch('http://127.0.0.1:5000/data');
        const data = await response.json();
        return data.attackTypes;
      } catch (error) {
        console.error('Error:', error);
        return [];
      }
    }

    async function renderGraph() {
      const attackTypes = await fetchAttackTypes();

      shuffleArray(attackTypes);

      attackTypes.forEach((type, index) => {
        const angle = index * (2 * Math.PI / attackTypes.length);
        const x = 200 * Math.cos(angle);
        const y = 200 * Math.sin(angle);
        graph.addNode(type, { label: type, x, y, size: 10, color: '#00f' });
      });

      attackTypes.forEach(type => {
        const otherNodes = attackTypes.filter(otherType => otherType !== type);
        const hasConnections = graph.neighbors(type).length > 0;
        if (!hasConnections) {
          const randomIndex = Math.floor(Math.random() * otherNodes.length);
          const randomType = otherNodes[randomIndex];
          graph.addEdge(type, randomType, { color: '#f00' });
        }
      });

      const sigmaInstance = new Sigma(graph, document.getElementById("container"));

      sigmaInstance.on('overNode', function(e) {
        e.data.node.color = '#f00';
        e.data.node.size *= 2;
        sigmaInstance.refresh();
      });

      sigmaInstance.on('outNode', function(e) {
        e.data.node.color = '#00f';
        e.data.node.size /= 2;
        sigmaInstance.refresh();
      });
    }

    renderGraph();
  </script>
</body>
</html>

nodes.json

"nodes": [
    {
      "color": "blue",
      "id": "59.166.0.9",
      "label": Exploit,
      "size": 10,
      "x": 0,
      "y": 0
    },
    {
      "color": "blue",
      "id": "149.171.126.1",
      "label": Fuzzing,
      "size": 10,
      "x": 0,
      "y": 0
    },
    {
      "color": "blue",
      "id": "59.166.0.2",
      "label": NaN,
      "size": 10,
      "x": 0,
      "y": 1
    },
    {
      "color": "blue",
      "id": "149.171.126.7",
      "label": NaN,
      "size": 10,
      "x": 0,
      "y": 1
    },
    {
      "color": "blue",
      "id": "59.166.0.9",
      "label": NaN,
      "size": 10,
      "x": 0,
      "y": 2
    },
    {
      "color": "blue",
      "id": "149.171.126.4",
      "label": NaN,
      "size": 10,
      "x": 0,
      "y": 2
    },
    {
      "color": "blue",
      "id": "59.166.0.0",
      "label": NaN,
      "size": 10,
      "x": 0,
      "y": 3
    },
    {
      "color": "blue",
      "id": "149.171.126.3",
      "label": NaN,
      "size": 10,
      "x": 0,
      "y": 3
    }
]

edges.json

"edges": [
    {
      "color": "purple",
      "id": "e1_1000",
      "size": 5,
      "source": "175.45.176.1",
      "target": "149.171.126.10"
    },
    {
      "color": "purple",
      "id": "e1_1001",
      "size": 5,
      "source": "175.45.176.1",
      "target": "149.171.126.10"
    },
    {
      "color": "purple",
      "id": "e1_1002",
      "size": 5,
      "source": "175.45.176.0",
      "target": "149.171.126.14"
    },
    {
      "color": "purple",
      "id": "e1_1003",
      "size": 5,
      "source": "149.171.126.18",
      "target": "175.45.176.3"
    },
    {
      "color": "purple",
      "id": "e1_1004",
      "size": 5,
      "source": "149.171.126.18",
      "target": "175.45.176.3"
    },
]

Image of the code I wrote while it is running

I need to show the incoming data

Processing the data sent as Json in the backend

graph_data = {"nodes": [], "edges": []}

def update_graph_data():
    global graph_data
    data_iterator = load_data()
    for i, data in enumerate(data_iterator):
        for index, row in data.iterrows():
            if row['attack_cat'] != "nan":
                graph_data["nodes"].append({"id": row['srcip'], "label": row['attack_cat'], "x": i, "y": index, "size": 10, "color": "blue"})
                graph_data["nodes"].append({"id": row['dstip'], "label": row['attack_cat'], "x": i, "y": index, "size": 10, "color": "blue"})
                if i > 0:
                    graph_data["edges"].append({"id": f"e{i}_{index}", "source": row['srcip'], "target": row['dstip'], "size": 5, "color": "purple"})
        time.sleep(1)

How to reset vue product filter?

I want to reset my product filter.
Filter work by same code

 filteredData: function () {
      var vm = this
      var sf = vm.startFloor;
      var ef = vm.endFloor;
      var sa = vm.startSquare;
      var ea = vm.endSquare;
      var sp = vm.startPrice;
      var ep = vm.endPrice;
      return _.filter(this.avalFloors, (function (data) {
        if ((_.isNull(sf) && _.isNull(ef)) && (_.isNull(sa) && _.isNull(ea)) && (_.isNull(sp) && _.isNull(ep))) {
          return true
        } else {
          var areaf = data.areaf;
          var floor = data.floorf;
          var pricef = data.pricef;
          return (floor >= sf && floor <= ef) && (areaf >= sa && areaf <= ea) && (pricef >= sp && pricef <= ep);
        }
      }))
    }

How I can reset this by @click button?

Remix V2 useLoaderData issue while running in dev mode

In a basic Remix V2 app, i need help understanding if the following is expected behavior, a bug in V2, or possibly a missing configuration option or setting.

I could not find anything related to this issue in the Remix documentation.

I created an demo Remix V2 app by running npx create-remix@latest

I wrote a simulated API backend method for basic testing which simply returns JSON data as retrieved from a JSON file:

export async function getStoredNotes() {
  const rawFileContent = await fs.readFile('notes.json', { encoding: 'utf-8' });
  const data = JSON.parse(rawFileContent);
  const storedNotes = data.notes ?? [];
  return storedNotes;
}

The client side consists of 2 simple pages that uses NavLink for navigation between the 2 pages:

import { NavLink } from '@remix-run/react';
...
<NavLink to="/">Home</NavLink>
<NavLink to="/notes">Notes</NavLink>

In the notes route, i have the following loader function defined which makes a call to my simulated API method:

export const loader:LoaderFunction = async () => {
  try {
    const notes = await getStoredNotes();
    return json(notes);

  } catch (error) {
    return json({ errorMessage: 'Failed to retrieve stored notes.', errorDetails: error }, { status: 400 });
  }
}

And in the notes main component function i receive that data using the useLoaderData hook and attempt to print the returned JSON data to the console:

export default function NotesView() {

  const notes = useLoaderData<typeof loader>();

  console.log("JSON Data retrieved:", notes);

  return (
    <main>
      <NoteList notes={notes as Note[] || []} />
    </main>
  )
}

When i run a build and subsequently serve the application everything is working correctly:

Initial page load receives the data successfully and prints the value to the console as JSON.

{"notes":[{"title":"my title","content":"my note","id":"2024-03-28T05:22:52.875Z"}]}

Navigating between the index route and back to the notes route using the NavLink is also working such that i see the data print to the console again, correctly on subsequent page visits.

When i run in dev mode using npx run dev the following problem occurs:

The initial page load coming from the dev server also loads correctly and prints the JSON to the console.

Navigating client side between the index route and back to the notes route using the NavLink causes an issue whereas the data that prints to the console is not JSON. Instead, i am seeing a strange output of an exported Javascript array definition:

export const notes = [
    {
        title: "my title",
        content: "my note",
        id: "2024-03-28T05:22:52.875Z"
    }
];

Again, to be clear, this behavior only occurs when navigating client side using NavLink or Link elements while running npx run dev.

Is this expected behavior when running in dev mode?

‘node: not found’ when using the ‘cross-env’ package

I’m trying to make a coding challenge involving firebase and next.js. The challenge includes a pre-configured project with some dependencies, including cross-env.

I already installed all dependencies using ‘yarn install’ as instructed but when I try to run ‘yarn dev’ so it uses an specific script file, I run into the following issue:

yarn run v1.22.21
$ bash ./scripts/dev.sh
/mnt/d/codechallenge/node_modules/.bin/cross-env: 12: node: not found
error Command failed with exit code 127.
info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.

The error that says ‘node: not found’ is the one that I don’t understand. This is my setup and what I currently tried:

  • I have node properly installed, version 21.6.2
  • I already uninstalled and installed all dependencies.
  • I installed the cross-env dependency as global using npm install --global cross-env and sudo npm install --global cross-env.
  • This is the first time I’ve run into this issue.
  • As reference, the line ’12’ that the error is referring to points to the following line of code in the dependency file: node "$basedir/../cross-env/src/bin/cross-env.js" "$@"

Do you know what can be causing this problem?

I appreciate your help and time.

Undo/Redo in Angular

I’m using Angular 7 in a system I’m building. Now I need to add an Undo/Redo feature to this application. What I’m looking for is, what are the best practices I should follow to do this? Do I need to use a state management library (NGRX, etc.) for efficiency and maintainability? Or would following a simple pattern (command pattern) be enough and lightweight? Note that the data structure of the system is nested (5 levels of nesting)

I’ve tried to implement a command design pattern for this.

next.js prerendering error with next-intl

Error occurred prerendering page “/en/500”.

I bought this error wirth reportToErrorTracking(error);

Error occurred prerendering page "/500". Read more: https://nextjs.org/docs/messages/prerender-error
Error
    at /home/serokdilo/DEV/lavenus/node_modules/next-intl/dist/production/react-client/index.js:1:171
    at c (/home/serokdilo/DEV/lavenus/.next/server/pages/_app.js:1:900)
    at Wc (/home/serokdilo/DEV/lavenus/node_modules/react-dom/cjs/react-dom-server.browser.production.min.js:68:44)
    at Zc (/home/serokdilo/DEV/lavenus/node_modules/react-dom/cjs/react-dom-server.browser.production.min.js:70:253)
    at Z (/home/serokdilo/DEV/lavenus/node_modules/react-dom/cjs/react-dom-server.browser.production.min.js:76:89)
    at $c (/home/serokdilo/DEV/lavenus/node_modules/react-dom/cjs/react-dom-server.browser.production.min.js:78:98)
    at bd (/home/serokdilo/DEV/lavenus/node_modules/react-dom/cjs/react-dom-server.browser.production.min.js:77:404)
    at Z (/home/serokdilo/DEV/lavenus/node_modules/react-dom/cjs/react-dom-server.browser.production.min.js:76:217)
    at Zc (/home/serokdilo/DEV/lavenus/node_modules/react-dom/cjs/react-dom-server.browser.production.min.js:74:209)
   Generating static pages (50/66) [   =] 
Error
    at /home/serokdilo/DEV/lavenus/node_modules/next-intl/dist/production/react-client/index.js:1:171
    at c (/home/serokdilo/DEV/lavenus/.next/server/pages/_app.js:1:900)
    at Wc (/home/serokdilo/DEV/lavenus/node_modules/react-dom/cjs/react-dom-server.browser.production.min.js:68:44)
    at Zc (/home/serokdilo/DEV/lavenus/node_modules/react-dom/cjs/react-dom-server.browser.production.min.js:70:253)
    at Z (/home/serokdilo/DEV/lavenus/node_modules/react-dom/cjs/react-dom-server.browser.production.min.js:76:89)
    at $c (/home/serokdilo/DEV/lavenus/node_modules/react-dom/cjs/react-dom-server.browser.production.min.js:78:98)
    at bd (/home/serokdilo/DEV/lavenus/node_modules/react-dom/cjs/react-dom-server.browser.production.min.js:77:404)
    at Z (/home/serokdilo/DEV/lavenus/node_modules/react-dom/cjs/react-dom-server.browser.production.min.js:76:217)
    at Zc (/home/serokdilo/DEV/lavenus/node_modules/react-dom/cjs/react-dom-server.browser.production.min.js:74:209)
    at Z (/home/serokdilo/DEV/lavenus/node_modules/react-dom/cjs/react-dom-server.browser.production.min.js:76:89)

Error occurred prerendering page "/es/500". Read more: https://nextjs.org/docs/messages/prerender-error
Error
    at /home/serokdilo/DEV/lavenus/node_modules/next-intl/dist/production/react-client/index.js:1:171
    at c (/home/serokdilo/DEV/lavenus/.next/server/pages/_app.js:1:900)
    at Wc (/home/serokdilo/DEV/lavenus/node_modules/react-dom/cjs/react-dom-server.browser.production.min.js:68:44)
    at Zc (/home/serokdilo/DEV/lavenus/node_modules/react-dom/cjs/react-dom-server.browser.production.min.js:70:253)
    at Z (/home/serokdilo/DEV/lavenus/node_modules/react-dom/cjs/react-dom-server.browser.production.min.js:76:89)
    at $c (/home/serokdilo/DEV/lavenus/node_modules/react-dom/cjs/react-dom-server.browser.production.min.js:78:98)
    at bd (/home/serokdilo/DEV/lavenus/node_modules/react-dom/cjs/react-dom-server.browser.production.min.js:77:404)
    at Z (/home/serokdilo/DEV/lavenus/node_modules/react-dom/cjs/react-dom-server.browser.production.min.js:76:217)
    at Zc (/home/serokdilo/DEV/lavenus/node_modules/react-dom/cjs/react-dom-server.browser.production.min.js:74:209)
    at Z (/home/serokdilo/DEV/lavenus/node_modules/react-dom/cjs/react-dom-server.browser.production.min.js:76:89)
Error
    at /home/serokdilo/DEV/lavenus/node_modules/next-intl/dist/production/react-client/index.js:1:171
    at c (/home/serokdilo/DEV/lavenus/.next/server/pages/_app.js:1:900)
    at Wc (/home/serokdilo/DEV/lavenus/node_modules/react-dom/cjs/react-dom-server.browser.production.min.js:68:44)
    at Zc (/home/serokdilo/DEV/lavenus/node_modules/react-dom/cjs/react-dom-server.browser.production.min.js:70:253)
    at Z (/home/serokdilo/DEV/lavenus/node_modules/react-dom/cjs/react-dom-server.browser.production.min.js:76:89)
    at $c (/home/serokdilo/DEV/lavenus/node_modules/react-dom/cjs/react-dom-server.browser.production.min.js:78:98)
    at bd (/home/serokdilo/DEV/lavenus/node_modules/react-dom/cjs/react-dom-server.browser.production.min.js:77:404)
    at Z (/home/serokdilo/DEV/lavenus/node_modules/react-dom/cjs/react-dom-server.browser.production.min.js:76:217)
    at Zc (/home/serokdilo/DEV/lavenus/node_modules/react-dom/cjs/react-dom-server.browser.production.min.js:74:209)
    at Z (/home/serokdilo/DEV/lavenus/node_modules/react-dom/cjs/react-dom-server.browser.production.min.js:76:89)

Error occurred prerendering page "/en/500". Read more: https://nextjs.org/docs/messages/prerender-error
Error
    at /home/serokdilo/DEV/lavenus/node_modules/next-intl/dist/production/react-client/index.js:1:171
    at c (/home/serokdilo/DEV/lavenus/.next/server/pages/_app.js:1:900)
    at Wc (/home/serokdilo/DEV/lavenus/node_modules/react-dom/cjs/react-dom-server.browser.production.min.js:68:44)
    at Zc (/home/serokdilo/DEV/lavenus/node_modules/react-dom/cjs/react-dom-server.browser.production.min.js:70:253)
    at Z (/home/serokdilo/DEV/lavenus/node_modules/react-dom/cjs/react-dom-server.browser.production.min.js:76:89)
    at $c (/home/serokdilo/DEV/lavenus/node_modules/react-dom/cjs/react-dom-server.browser.production.min.js:78:98)
    at bd (/home/serokdilo/DEV/lavenus/node_modules/react-dom/cjs/react-dom-server.browser.production.min.js:77:404)
    at Z (/home/serokdilo/DEV/lavenus/node_modules/react-dom/cjs/react-dom-server.browser.production.min.js:76:217)
    at Zc (/home/serokdilo/DEV/lavenus/node_modules/react-dom/cjs/react-dom-server.browser.production.min.js:74:209)
 ✓ Generating static pages (66/66) 
> Export encountered errors on following paths:
        /_error: /500
        /_error: /en/500
        /_error: /es/500
        /layout
        /layout: /en/layout
        /layout: /es/layout

u [Error]: MISSING_MESSAGE

I get this error whenever I try to build.

u [Error]: MISSING_MESSAGE
    at /home/serokdilo/DEV/lavenus/node_modules/use-intl/dist/production/createFormatter-46d61ef5.js:1:1859
    at exports.createBaseTranslator (/home/serokdilo/DEV/lavenus/node_modules/use-intl/dist/production/createFormatter-46d61ef5.js:1:1909)
    at /home/serokdilo/DEV/lavenus/node_modules/use-intl/dist/production/react.js:1:1412
    at Object.Kc [as useMemo] (/home/serokdilo/DEV/lavenus/node_modules/react-dom/cjs/react-dom-server.browser.production.min.js:60:240)
    at exports.useMemo (/home/serokdilo/DEV/lavenus/node_modules/react/cjs/react.production.min.js:25:208)
    at /home/serokdilo/DEV/lavenus/node_modules/use-intl/dist/production/react.js:1:1397
    at exports.useTranslations (/home/serokdilo/DEV/lavenus/node_modules/use-intl/dist/production/react.js:1:1590)
    at /home/serokdilo/DEV/lavenus/node_modules/next-intl/dist/production/react-client/index.js:1:140
    at m (/home/serokdilo/DEV/lavenus/.next/server/chunks/388.js:1:3940)
    at Wc (/home/serokdilo/DEV/lavenus/node_modules/react-dom/cjs/react-dom-server.browser.production.min.js:68:44) {
  code: 'MISSING_MESSAGE',
  originalMessage: undefined
   Generating static pages (50/66) [ ===] 
u [Error]: MISSING_MESSAGE
    at /home/serokdilo/DEV/lavenus/node_modules/use-intl/dist/production/createFormatter-46d61ef5.js:1:1859
    at exports.createBaseTranslator (/home/serokdilo/DEV/lavenus/node_modules/use-intl/dist/production/createFormatter-46d61ef5.js:1:1909)
    at /home/serokdilo/DEV/lavenus/node_modules/use-intl/dist/production/react.js:1:1412
    at Object.Kc [as useMemo] (/home/serokdilo/DEV/lavenus/node_modules/react-dom/cjs/react-dom-server.browser.production.min.js:60:240)
    at exports.useMemo (/home/serokdilo/DEV/lavenus/node_modules/react/cjs/react.production.min.js:25:208)
    at /home/serokdilo/DEV/lavenus/node_modules/use-intl/dist/production/react.js:1:1397
    at exports.useTranslations (/home/serokdilo/DEV/lavenus/node_modules/use-intl/dist/production/react.js:1:1590)
    at /home/serokdilo/DEV/lavenus/node_modules/next-intl/dist/production/react-client/index.js:1:140
    at c (/home/serokdilo/DEV/lavenus/.next/server/pages/_app.js:1:900)
    at Wc (/home/serokdilo/DEV/lavenus/node_modules/react-dom/cjs/react-dom-server.browser.production.min.js:68:44) {
  code: 'MISSING_MESSAGE',
  originalMessage: undefined
}
u [Error]: MISSING_MESSAGE
    at /home/serokdilo/DEV/lavenus/node_modules/use-intl/dist/production/createFormatter-46d61ef5.js:1:1859
    at exports.createBaseTranslator (/home/serokdilo/DEV/lavenus/node_modules/use-intl/dist/production/createFormatter-46d61ef5.js:1:1909)
    at /home/serokdilo/DEV/lavenus/node_modules/use-intl/dist/production/react.js:1:1412
    at Object.Kc [as useMemo] (/home/serokdilo/DEV/lavenus/node_modules/react-dom/cjs/react-dom-server.browser.production.min.js:60:240)
    at exports.useMemo (/home/serokdilo/DEV/lavenus/node_modules/react/cjs/react.production.min.js:25:208)
    at /home/serokdilo/DEV/lavenus/node_modules/use-intl/dist/production/react.js:1:1397
    at exports.useTranslations (/home/serokdilo/DEV/lavenus/node_modules/use-intl/dist/production/react.js:1:1590)
    at /home/serokdilo/DEV/lavenus/node_modules/next-intl/dist/production/react-client/index.js:1:140
    at u (/home/serokdilo/DEV/lavenus/.next/server/pages/_app.js:1:224)
    at Wc (/home/serokdilo/DEV/lavenus/node_modules/react-dom/cjs/react-dom-server.browser.production.min.js:68:44) {
  code: 'MISSING_MESSAGE',
  originalMessage: undefined
}
u [Error]: MISSING_MESSAGE
    at /home/serokdilo/DEV/lavenus/node_modules/use-intl/dist/production/createFormatter-46d61ef5.js:1:1859
    at exports.createBaseTranslator (/home/serokdilo/DEV/lavenus/node_modules/use-intl/dist/production/createFormatter-46d61ef5.js:1:1909)
    at /home/serokdilo/DEV/lavenus/node_modules/use-intl/dist/production/react.js:1:1412
    at Object.Kc [as useMemo] (/home/serokdilo/DEV/lavenus/node_modules/react-dom/cjs/react-dom-server.browser.production.min.js:60:240)
    at exports.useMemo (/home/serokdilo/DEV/lavenus/node_modules/react/cjs/react.production.min.js:25:208)
    at /home/serokdilo/DEV/lavenus/node_modules/use-intl/dist/production/react.js:1:1397
    at exports.useTranslations (/home/serokdilo/DEV/lavenus/node_modules/use-intl/dist/production/react.js:1:1590)
    at /home/serokdilo/DEV/lavenus/node_modules/next-intl/dist/production/react-client/index.js:1:140
    at c (/home/serokdilo/DEV/lavenus/.next/server/pages/_app.js:1:900)
    at Wc (/home/serokdilo/DEV/lavenus/node_modules/react-dom/cjs/react-dom-server.browser.production.min.js:68:44) {
  code: 'MISSING_MESSAGE',
  originalMessage: undefined
}
u [Error]: MISSING_MESSAGE
    at /home/serokdilo/DEV/lavenus/node_modules/use-intl/dist/production/createFormatter-46d61ef5.js:1:1859
    at exports.createBaseTranslator (/home/serokdilo/DEV/lavenus/node_modules/use-intl/dist/production/createFormatter-46d61ef5.js:1:1909)
    at /home/serokdilo/DEV/lavenus/node_modules/use-intl/dist/production/react.js:1:1412
    at Object.Kc [as useMemo] (/home/serokdilo/DEV/lavenus/node_modules/react-dom/cjs/react-dom-server.browser.production.min.js:60:240)
    at exports.useMemo (/home/serokdilo/DEV/lavenus/node_modules/react/cjs/react.production.min.js:25:208)
    at /home/serokdilo/DEV/lavenus/node_modules/use-intl/dist/production/react.js:1:1397
    at exports.useTranslations (/home/serokdilo/DEV/lavenus/node_modules/use-intl/dist/production/react.js:1:1590)
    at /home/serokdilo/DEV/lavenus/node_modules/next-intl/dist/production/react-client/index.js:1:140
    at u (/home/serokdilo/DEV/lavenus/.next/server/pages/_app.js:1:224)
    at Wc (/home/serokdilo/DEV/lavenus/node_modules/react-dom/cjs/react-dom-server.browser.production.min.js:68:44) {
  code: 'MISSING_MESSAGE',
  originalMessage: undefined
 ✓ Generating static pages (66/66) 
 ✓ Collecting build traces    
 ✓ Finalizing page optimization  

and my source _app.js code

import "../styles/globals.css";
import "../styles/index.css";

import JsonLdComponent from "../SEO/jsonldConfig";
import NextSeoComponent from "../SEO/NextSeoConfig";
import { useEffect, useState } from "react";
import Preloader from "../components/PreLoader";
import Router from 'next/router';
import NProgress from 'nprogress'; // Yükleme bar stil dosyasını dahil edin
import 'nprogress/nprogress.css'; // NProgress stilini dahil edin

import {useRouter} from 'next/router';
import {NextIntlClientProvider, IntlErrorCode} from 'next-intl';

export default function App({ Component, pageProps }) {
  const router = useRouter();
  const [loading, setLoading] = useState(false);
  const [longLoading, setLongLoading] = useState(false);
  let timer;

  NProgress.configure({ showSpinner: false }); // İsteğe bağlı konfigürasyon

//  useEffect(() => {
//    const timero = setTimeout(() => {
//      setLongLoading(false);
//      setLoading(false);
//    }, 2000);
//
//    return () => clearTimeout(timero);
//  }, []);


function onError(error) {
  if (error.code === IntlErrorCode.MISSING_MESSAGE) {
    console.error(error);
  } else {
    reportToErrorTracking(error);
  }
}
 
function getMessageFallback({namespace, key, error}) {
  const path = [namespace, key].filter((part) => part != null).join('.');
 
  if (error.code === IntlErrorCode.MISSING_MESSAGE) {
    return path + ' is not yet translated';
  } else {
    return 'Dear developer, please fix this message: ' + path;
  }
}
  
    useEffect(() => {
      const handleStart = () => {
        setLoading(true);
        timer = setTimeout(() => {
          setLongLoading(true);
        }, 300);
      };
  
      const handleStop = () => {
        setLoading(false);
        if (timer) clearTimeout(timer);
        setLongLoading(false);
      };
  
      Router.events.on('routeChangeStart', handleStart);
      Router.events.on('routeChangeComplete', handleStop);
      Router.events.on('routeChangeError', handleStop);
  
      // Component unmount edildiğinde event listener'ları temizle
      return () => {
        clearTimeout(timer);
        Router.events.off('routeChangeStart', handleStart);
        Router.events.off('routeChangeComplete', handleStop);
        Router.events.off('routeChangeError', handleStop);
      };
    }, []);


    useEffect(() => {
      if (loading) {
        NProgress.start();
      } else {
        NProgress.done();
      }
    }, [loading]);

  return (
      <NextIntlClientProvider onError={onError} getMessageFallback={getMessageFallback} locale={router.locale} timeZone="Europe/Madrid" messages={pageProps.messages}>
        <NextSeoComponent />
        <JsonLdComponent />
        <Preloader loading={longLoading} />
        <Component {...pageProps} loading={loading} />
      </NextIntlClientProvider>
  );
}

Although this error is not received at the developer stage, it is also received during the build phase.
I couldn’t find this week’s solution anywhere, please help.

I couldn’t even find what was wrong

Trouble with Puppeteer Cluster and Excel4node: Not all data is being written to Excel

I’m encountering an issue while trying to scrape data using Puppeteer Cluster and write it to an Excel file using Excel4node.

Here’s a summary of the script’s functionality:

I’m using Puppeteer Cluster to scrape data from multiple URLs concurrently.
For each URL, I scrape various pieces of information from the webpage.
I’m using a write queue mechanism to write the scraped data to an Excel file using Excel4node.

The problem is that while some data is successfully written to the Excel file, not all of it is being captured. It seems like some rows are missing in the Excel file compared to the number of URLs processed.
When I set maxConcurrency to 1 it works fine.

code link: code

I’ve already tried to troubleshoot the issue by:

Checking for errors: There are no error messages in the console logs.
Verifying data retrieval: Data retrieval from the web pages seems to be working correctly.

Despite these efforts, I’m still unable to pinpoint the exact cause of the problem. Any insights or suggestions on how to troubleshoot and resolve this issue would be greatly appreciated.

Thank you in advance for your help!

Getting right answer on console.log but return function not giving right answer

I am writing code for Roman Numeral Converter in the browser, currently learning Javascript. The problem is right on checking return statements in console.log I am getting the right answers, but somehow all tests are failing.

CODE:

let resstr = "";
let resarr = [];
function convertToRoman(num) {
  let robj = {
    M: 1000,
    CM: 900,
    D: 500,
    CD: 400,
    C: 100,
    XC: 90,
    L: 50,
    XL: 40,
    X: 10,
    IX: 9,
    V: 5,
    IV: 4,
    I: 1,
  };
  let okeys = Object.keys(robj); //getting keys for iteration

  //loop to check numbers and adding roman numerals in array
  okeys.some((key) => {
    if (num >= robj[key]) {
      //console.log(robj[key]);
      resarr.push(key);
      num = num - robj[key];
      //console.log("number after subtraction is: " + num);
      return true;
    }
  });

  //end cases
  if (num === 0) {
    resstr = resarr.join("").toString();
    console.log("operation done", resstr);
    return resstr;
  } else if (num !== 0) {
    console.log("no 0", num);
    return convertToRoman(num);
  } else {
    console.log("ended");
    return true;
  }
  // console.log(resstr);
  // return resstr;
}

For convertToRoman(3999), convertToRoman(1), convertToRoman(2) etc. I am getting the right answers on console.log, but browser tests are all failing like it is getting something else than the right answer.