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

95
Vistas
Issue when a Proxy object is being resolved as a Promise

As background, I have an async function that does some logic, and eventually (if the browser supports it) returns a Proxy object. This is to support older legacy code that expected an object which can have many different available functions, depending on the name of the controller requested. The controller can have many different functions on it, it depends on the API functions that are available on the controller, so we just allow any function name. For example a controller can have a "controller.xyz()" or "controller.test()" or even "controller.then()".

let x = 0;
function getController() {
  return new Proxy({}, {get: () => () => `test${x}`});
}
async function getControllerAsync() {
  return getController();
}
function test(controller) {
  console.log(controller.x());
}
test(getController());
getControllerAsync().then(test);
// Expected: test0 and test1 should output to console
// Actual: only test0 is output, the getControllerAsync() promise never resolves

The problem, though (I think), is that the async function (or a Promise resolve function) thinks the Proxy object is a "thenable" object, or at least I think so. I don't understand, though, if that were the case why would the the Promise not resolve to a string instead of never resolving?

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