There is such a code

static GetPromise(Target: NetObjectinterface, name: any, args: any[]) { let key = window.CallNetMethod(0, "GetUniqueString"); let promise = new Promise((resolve, reject) => { NetObject.PromiseDictioanary.set(key, { resolve: resolve, reject: reject }); window.CallAsyncNetObjectFunction(Target.Id, name, key, args); }); return promise; } static SetPromiseResult(Successfully: boolean, TaskId: string, result: any) { let item = NetObject.PromiseDictioanary.get(TaskId); try { NetObject.PromiseDictioanary.delete(TaskId); //result = NetObject.WrapResult(result, true); if (Successfully) item.resolve(result); // Ошибка при установке Proxy else item.reject(result); } catch (e) { item.reject("ошибка установки асинхронного результата " + e); alert("ошибка установки асинхронного результата " + e); } } 

If the result is an object type, then I need to wrap it in Proxy.

 static WrapResult(value: any, ReturnProxy: boolean = false): any { if (typeof value == "object") { if ("IsNetObject" in value) { let res = getNetObject(value.Id); if (ReturnProxy) return new Proxy(res, NetObjectHandler); else return res } } return value; } 

But if I install

 item.resolve(NetObject.WrapResult(result, true)); 

then the error "not found then" falls out

Exit after getting the result set.

 let document = await Context.async.OpenAsync(address); document = NetObject.WrapResult(document, true); 

Perhaps the problem is that the source for the proxy is the function

 function getNetObject(id: number): NetObjectinterface { let netObject = <NetObjectinterface>function (start: number) { }; netObject.Id = id; netObject.isNetObject = true; netObject[NetObject.isNetclass] = true; netObject.Execute = NetObject.Execute; netObject.CallAsProp = NetObject.CallAsProp; return netObject; } 

And she really has no then

Here I posted the source code CEF, Es6, Angular 2, TypeScript using .Net Core classes to expand the possibilities

where can i try this bug

  • Error falls out where ? Give the code where the error occurs, not your thoughts on this topic! - Pavel Mayorov
  • So I wrote item.resolve (NetObject.WrapResult (result, true)); - Serginio
  • Is it a matter of principle to reproduce the error that the item is taken from the PromiseDictioanary ? What will happen if you create a new Promise , and not take the old one? - Pavel Mayorov
  • one
    What difference do you make there? Until you localize the error - all this is a guessing on a coffee goose! Give a minimal reproducible example if you really need an answer to your question. - Pavel Mayorov
  • one
    @Serginio, make a running example. - Qwertiy

0