* Calls the callback and handle node EAGAIN errors.
(cb)
| 50 | * Calls the callback and handle node EAGAIN errors. |
| 51 | */ |
| 52 | function handleEAGAIN(cb) { |
| 53 | while (true) { |
| 54 | try { |
| 55 | return cb(); |
| 56 | } catch (e) { |
| 57 | if (e && e.code === "EAGAIN") { |
| 58 | // Presumably this means we're in node and tried to read from/write to |
| 59 | // an O_NONBLOCK file descriptor. Synchronously sleep for 10ms then try |
| 60 | // again. In case for some reason we fail to sleep, propagate the error |
| 61 | // (it will turn into an EOFError). |
| 62 | if (syncSleep(10)) { |
| 63 | continue; |
| 64 | } |
| 65 | } |
| 66 | throw e; |
| 67 | } |
| 68 | } |
| 69 | } |
| 70 | |
| 71 | function readWriteHelper(stream, cb, method) { |
| 72 | let nbytes; |
no test coverage detected
searching dependent graphs…