| 617 | // Given a promise stub (still wrapped in a Proxy), pull the remote promise and deliver the |
| 618 | // payload. This is a helper used to implement the then/catch/finally methods of RpcPromise. |
| 619 | async function pullPromise(promise: RpcPromise): Promise<unknown> { |
| 620 | let {hook, pathIfPromise} = promise[RAW_STUB]; |
| 621 | if (pathIfPromise!.length > 0) { |
| 622 | // If this isn't the root promise, we have to clone it and pull the clone. This is a little |
| 623 | // weird in terms of disposal: There's no way for the app to dispose/cancel the promise while |
| 624 | // waiting because it never actually got a direct disposable reference. It has to dispose |
| 625 | // the result. |
| 626 | hook = hook.get(pathIfPromise!); |
| 627 | } |
| 628 | let payload = await hook.pull(); |
| 629 | return payload.deliverResolve(); |
| 630 | } |
| 631 | |
| 632 | // ======================================================================================= |
| 633 | // RpcPayload |