| 8683 | } |
| 8684 | |
| 8685 | async _waitForNextItem(timeout) { |
| 8686 | return new Promise((resolve, reject) => { |
| 8687 | this._resolve = resolve; |
| 8688 | let timeoutId; |
| 8689 | if (timeout !== undefined) { |
| 8690 | // Create the error object in the outer scope in order |
| 8691 | // to get the full stack trace. |
| 8692 | let error = new Error('Stream consumer iteration timed out'); |
| 8693 | (async () => { |
| 8694 | let delay = wait(timeout); |
| 8695 | timeoutId = delay.timeoutId; |
| 8696 | await delay.promise; |
| 8697 | error.name = 'TimeoutError'; |
| 8698 | delete this._resolve; |
| 8699 | reject(error); |
| 8700 | })(); |
| 8701 | } |
| 8702 | this._timeoutId = timeoutId; |
| 8703 | }); |
| 8704 | } |
| 8705 | |
| 8706 | async next() { |
| 8707 | this.stream.setConsumer(this.id, this); |