(buffers, position, signal)
| 795 | // Writev with EAGAIN retry. On partial write, concatenates remaining |
| 796 | // buffers and falls back to writeAll (same approach as WriteStream). |
| 797 | async function writevAll(buffers, position, signal) { |
| 798 | asyncPending = true; |
| 799 | try { |
| 800 | let totalSize = 0; |
| 801 | for (let i = 0; i < buffers.length; i++) { |
| 802 | totalSize += buffers[i].byteLength; |
| 803 | } |
| 804 | |
| 805 | let retries = 0; |
| 806 | while (totalSize > 0) { |
| 807 | const bytesWritten = (await PromisePrototypeThen( |
| 808 | binding.writeBuffers(fd, buffers, position, kUsePromises), |
| 809 | undefined, |
| 810 | handleErrorFromBinding, |
| 811 | )) || 0; |
| 812 | |
| 813 | signal?.throwIfAborted(); |
| 814 | |
| 815 | if (bytesWritten === 0) { |
| 816 | if (++retries > 5) { |
| 817 | throw new ERR_OPERATION_FAILED('writev failed after retries'); |
| 818 | } |
| 819 | } else { |
| 820 | retries = 0; |
| 821 | } |
| 822 | |
| 823 | totalBytesWritten += bytesWritten; |
| 824 | totalSize -= bytesWritten; |
| 825 | if (position >= 0) position += bytesWritten; |
| 826 | |
| 827 | if (totalSize > 0) { |
| 828 | // Partial write - concatenate remaining and use writeAll. |
| 829 | const remaining = Buffer.concat(buffers); |
| 830 | const wrote = bytesWritten; |
| 831 | // writeAll is already inside asyncPending = true, but |
| 832 | // writeAll sets it again - that's fine (idempotent). |
| 833 | await writeAll(remaining, wrote, remaining.length - wrote, |
| 834 | position, signal); |
| 835 | return; |
| 836 | } |
| 837 | } |
| 838 | } finally { |
| 839 | asyncPending = false; |
| 840 | } |
| 841 | } |
| 842 | |
| 843 | // Synchronous write with EAGAIN retry. Throws on I/O error. |
| 844 | // Used by writeSync for the full write, and by writevSync for |
no test coverage detected
searching dependent graphs…