| 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 | |