Parsoid has this pattern to env.log('fatal', (or fatal/request to return a HTTP 500) when it enters a bad state (ie. catching a thrown error). I'm not too keen on it and would like to see errors returned to callers, rather than magically killing the process with the logger. We also ran into a bug on an old version of express where trying to write headers when content has already been sent gets into an infinite loop, which is why our api utils have all these responseSent flags. That happened when the logger sent a 500 midstream but then the async processing of the page finished and tried to send an (albeit undesirable) response.
I did some preliminary inspection of what it's going to take for a refactor.
- The token transformers need to emit errors and handle error events.
2) The serializer has all these cbs which aren't really callbacks, they are accumulators. We should extend that to accumulate errors as well (as the first arg). Then when the serialization is done, return both.