* Emits the 'error' event and callbacks items that haven't been written and clears them from the queue. * @param err
(err)
| 292 | * @param err |
| 293 | */ |
| 294 | setWriteError(err) { |
| 295 | err.isSocketError = true; |
| 296 | this.error = new types.DriverError('Socket was closed'); |
| 297 | this.error.isSocketError = true; |
| 298 | // Use an special flag for items that haven't been written |
| 299 | this.error.requestNotWritten = true; |
| 300 | this.error.innerError = err; |
| 301 | const q = this.queue; |
| 302 | // Not more items can be added to the queue. |
| 303 | this.queue = utils.emptyArray; |
| 304 | for (let i = 0; i < q.length; i++) { |
| 305 | const item = q[i]; |
| 306 | // Use the error marking that it was not written |
| 307 | item.callback(this.error); |
| 308 | } |
| 309 | } |
| 310 | } |
| 311 | |
| 312 | module.exports = { FrameWriter, WriteQueue }; |