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

97
Visualizações
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 à 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