-
Notifications
You must be signed in to change notification settings - Fork 6
Open
Labels
Description
The problem is that atm we take over response handling (by returning h.abandon) which also means headers handling.
Doing cors handling ourselves would be a bit much, it would be nicer if we could just let hapi do that.
The proposed solution is to properly return/handle the transform streams we use back to hapi and then continue the lifecycle by returning h.continue.
For csv (works):
- Set
csvStream._readableState.objectMode = false;and don't piperes- Quoting @kanongil (who helped a lot with these initial findings 🙏)
It works because the implementation doesn't actually use objectMode for the output, and this is a way to change the mode for only that end
- I logged an issue on
fast-csvto actually fix this [BUG] readable stream part of CsvFormatterStream is in objectMode C2FO/fast-csv#319
- Set the headers on a
headersproperty of thecsvStreamso that hapi will pick them up - Return
csvStream
For Excel (not tested):
- Pass a duplex stream to
WorkbookWriterthat has its readable side not in object mode - Set the headers on a
headersproperty of the duplex stream so that hapi will pick them up - Pass the duplex stream to hapi
There is branch with tests and a working csv version here: https://github.com/Salesflare/hapi-csv/tree/cors-and-lifecycle-fix
Reactions are currently unavailable