Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

88
Views
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
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!