(buf, offset, length, position, signal)
| 761 | |
| 762 | // Write a single buffer with EAGAIN retry (up to 5 retries). |
| 763 | async function writeAll(buf, offset, length, position, signal) { |
| 764 | asyncPending = true; |
| 765 | try { |
| 766 | let retries = 0; |
| 767 | while (length > 0) { |
| 768 | const bytesWritten = (await PromisePrototypeThen( |
| 769 | binding.writeBuffer(fd, buf, offset, length, position, |
| 770 | kUsePromises), |
| 771 | undefined, |
| 772 | handleErrorFromBinding, |
| 773 | )) || 0; |
| 774 | |
| 775 | signal?.throwIfAborted(); |
| 776 | |
| 777 | if (bytesWritten === 0) { |
| 778 | if (++retries > 5) { |
| 779 | throw new ERR_OPERATION_FAILED('write failed after retries'); |
| 780 | } |
| 781 | } else { |
| 782 | retries = 0; |
| 783 | } |
| 784 | |
| 785 | totalBytesWritten += bytesWritten; |
| 786 | offset += bytesWritten; |
| 787 | length -= bytesWritten; |
| 788 | if (position >= 0) position += bytesWritten; |
| 789 | } |
| 790 | } finally { |
| 791 | asyncPending = false; |
| 792 | } |
| 793 | } |
| 794 | |
| 795 | // Writev with EAGAIN retry. On partial write, concatenates remaining |
| 796 | // buffers and falls back to writeAll (same approach as WriteStream). |
no test coverage detected
searching dependent graphs…