Bugfix: emit errors correctly for streaming apis.

Previously errors where only handled for callback based api's. This now emits `error` events correctly when using the streaming api.