`Tried to abort stream due to encountering an error, but the aborting itself failed`,
`Original error message: ${error.message}`,
`Abort failure message: ${abortError.message}`
].join("\n");
// FIXME: Make this some sort of chained error
letcombinedError=newError(message);
combinedError.stack=abortError.stack;// HACK
throwcombinedError;
}
}
}
},
[states.ABORTED]:async()=>{
result=awaitonAbort(abortMarker.cause);
state=states.ABORT_THROW_CAUSE;
},
[states.ABORT_THROW_CAUSE]:async()=>{
// NOTE: This ensures that the original error causing the abort is thrown exactly once
state=states.ABORT_HANDLED;
throwabortMarker.cause;
},
[states.ABORT_HANDLED]:async()=>{
throwabortMarker;
},
[states.ENDED]:async()=>{
// Note: we *always* return a value when handling the end of the stream - that is intentional. This is necessary because the end can only ever be reached as the ultimate result of a read call on this stream, and that call is expected to return a value. If we only returned a value when there's an onEnd handler producing one, then it would be possible in some cases for the handler to not produce any result, causing an entirely valid read call to result in a thrown EndOfStream error in the next state. That error should only be thrown if something *continues* to try and read from it, not at the first moment that the end is reached.