MCPcopy
hub / github.com/cloudflare/capnweb / resolve

Method resolve

src/rpc.ts:575–597  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

573 }
574 if (!exp.pull) {
575 let resolve = async () => {
576 let hook = exp.hook;
577 for (;;) {
578 let payload = await hook.pull();
579 if (payload.value instanceof RpcStub) {
580 let {hook: inner, pathIfPromise} = unwrapStubAndPath(payload.value);
581 if (pathIfPromise && pathIfPromise.length == 0) {
582 if (this.getImport(hook) === undefined) {
583 // Optimization: The resolution is just another promise, and it is not a promise
584 // pointing back to the peer. So if we send a resolve message, it's just going to
585 // resolve to another new promise export, which is just going to have to wait for
586 // another resolve message later. This intermediate resolve message gives the peer
587 // no useful information, so let's skip it and just wait for the chained
588 // resolution.
589 hook = inner;
590 continue;
591 }
592 }
593 }
594
595 return payload;
596 }
597 };
598
599 let autoRelease = exp.autoRelease;
600

Callers 15

getFunction · 0.45
rpcPromiseFunction · 0.45
fakeRpcPromiseFunction · 0.45
getBestFriendMethod · 0.45
getDataMethod · 0.45
postMethod · 0.45
listPostsMethod · 0.45
getBestFriendMethod · 0.45
getBestFriendMethod · 0.45

Calls 3

getImportMethod · 0.95
unwrapStubAndPathFunction · 0.85
pullMethod · 0.45

Tested by 15

rpcPromiseFunction · 0.36
fakeRpcPromiseFunction · 0.36
getBestFriendMethod · 0.36
getDataMethod · 0.36
postMethod · 0.36
listPostsMethod · 0.36
getBestFriendMethod · 0.36
getBestFriendMethod · 0.36
nextMethod · 0.36
getWorkerMethod · 0.36
getCounterMethod · 0.36
getBestFriendMethod · 0.36