Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

170
Visualizações
node.js client side errors not showing in console

I am on a school Chromebook, where developer tools are disabled. I sometimes coded on node.js, having server-side and client-side code. But, as developer tools are disabled, I can't check errors on the client-side, as to only find that it sometimes just stops working without a clue as to what is wrong. I have had this issue a whole lot whenever coding client-side code.

How could I detect and identify the error with only access visually to the node.js console, as well as express and socket.io?

For example,

const express=require("express");
const app = express();
const http = require('http').Server(app);
const io = require('socket.io')(http);
app.use(
  '/client', 
  express.static(__dirname + '/client')
);
app.get('/', (req, res) => {
  res.sendFile(__dirname + '/client/index.html');
  console.log("sending site");
});
http.listen(3000, () => {
  console.log('listening on *:3000 (http.listen)');
});

io.on('connection', (socket) => {
  socket.emit("ERRORNOW",26);
});
//"<script src="/socket.io/socket.io.js"></script>" assumed to be in HTML file
var socket=io();

socket.on("ERRORNOW",()=>{
  if("this doesnt have an ending curlybracket){

  //} 
  //this is the error it doesnt have the ending curly bracket, 
  //but it doesn't show in the node.js console 
  //(at least on browser IDEs like repl.it), 
  //and debugging without the developer tools 
  //can be infuriating to say the least
});

The question is How can I identify a node.js client-side error on a web-based IDE without developer tools?

about 4 years ago · Juan Pablo Isaza
1 Respostas
Responde à pergunta

0

I have already had this issue a while ago, and due to the lack of developer tools on school Chromebooks, found the solution on my own, but I just thought that maybe I should also put it here.

My solution, as simple as it may be, is to just use a try-catch statement and send the error to the node.js console. It took a while to figure that out...

So, if you don't already have it, you would need a function that when triggered from the client side can log something into the console, inside of the io.on("connection",()=>{}); thing, like so:

io.on("connection",()=>{
  socket.on("log", input=>{
    console.log(input);
  });
});

For example, if everything runs off of a single function that is triggered really fast (specific, but relevant to me, as I make web games), or just off of something, you can run it off of a function inside a try catch, like so:

//"<script src="/socket.io/socket.io.js"></script>" assumed to be in HTML file
var socket=io();
try{
socket.on("ERRORNOW",()=>{
  try{
  if("this doesnt have an ending curlybracket){

  //} 
  }catch(error){
    socket.emit("log",error);
  }
});
}catch(error){
  socket.emit("log",error);
}

So now, with this simple solution, you can stop commenting out 90% of your code to find that one error that makes it stop working while breaking it further by accidentally commenting out parts that help it to work in the first place!

about 4 years ago · Juan Pablo Isaza Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda