Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

235
Vistas
Mutex timeout in javscript does'nt show on what line in code the error occurs

I use Node v16.14.2 and run this program in the command prompt.

I have a little problem with using Mutex in javascript. The Mutex itself do work but sometimes it takes to long to aquire the Mutex and I run into the error:

C:\myproject\node_modules\async-mutex\lib\errors.js:4
exports.E_TIMEOUT = new Error('timeout while waiting for mutex to become available');
                    ^

Error: timeout while waiting for mutex to become available
    at Object.<anonymous> (C:\myproject\node_modules\async-mutex\lib\errors.js:4:21)
    at Module._compile (node:internal/modules/cjs/loader:1103:14)
    at Object.Module._extensions..js (node:internal/modules/cjs/loader:1157:10)
    at Module.load (node:internal/modules/cjs/loader:981:32)
    at Function.Module._load (node:internal/modules/cjs/loader:822:12)
    at Module.require (node:internal/modules/cjs/loader:1005:19)
    at require (node:internal/modules/cjs/helpers:102:18)
    at Object.<anonymous> (C:\myproject\node_modules\async-mutex\lib\Semaphore.js:4:16)
    at Module._compile (node:internal/modules/cjs/loader:1103:14)
    at Object.Module._extensions..js (node:internal/modules/cjs/loader:1157:10)

I have 2 things I wonder about:

  1. The error message doesn't show on what line this error occurs in my code which is a problem because I have perheps 20 different mutexes and I don't know which one has the problem. How to know on what line in my code this error occurs? (All other types of errors that is not related to the mutex shows which line the error occurs to mention)

  2. Is there a problem to let the code aquire the mutex anyway even if it is not avaliable (which probably is not a good idéa but still?)

Test code to reproduce the error. I have nested the same mutex just to illustrate the error.

var Mutex = require('async-mutex').Mutex;
var withTimeout = require('async-mutex').withTimeout;

const mutexWithTimeout = withTimeout(new Mutex(), 5000); //5 second timeout
_testfunction();
async function _testfunction() { 


    console.log("starting...");

    await mutexWithTimeout.runExclusive(async () => {

        console.log("I am inside the mutex now...");
        await mutexWithTimeout.runExclusive(async () => {
            console.log("Timeout will happen here because I am nested just to reproduce the error");

        });
    });
}

about 4 years ago · Juan Pablo Isaza
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda