diff --git a/pystorm/serializers/serializer.py b/pystorm/serializers/serializer.py
index 03a15de..58f6a0e 100644
--- a/pystorm/serializers/serializer.py
+++ b/pystorm/serializers/serializer.py
@@ -4,6 +4,8 @@ each serializer a Java counterpart needs to exist.
 
 from __future__ import absolute_import, print_function, unicode_literals
 
+from ..exceptions import StormWentAwayError
+
 
 class Serializer(object):
 
@@ -21,9 +23,12 @@ class Serializer(object):
     def send_message(self, msg_dict):
         """Serialize a message dictionary and write it to the output stream."""
         with self._writer_lock:
-            self.output_stream.flush()
-            self.output_stream.write(self.serialize_dict(msg_dict))
-            self.output_stream.flush()
+            try:
+                self.output_stream.flush()
+                self.output_stream.write(self.serialize_dict(msg_dict))
+                self.output_stream.flush()
+            except IOError:
+                raise StormWentAwayError()
 
     def serialize_dict(self, msg_dict):
         """Convert a message dictionary to bytes.  Used by send_message"""

IOError is raised instead of StormWentAwayError if pipe breaks during send_message
```
IOError: [Errno 32] Broken pipe
(2 additional frame(s) were not displayed)
...
  File "pystorm/component.py", line 471, in run
    self._handle_run_exception(e)
  File "pystorm/component.py", line 483, in _handle_run_exception
    self.raise_exception(exc)
  File "pystorm/component.py", line 321, in raise_exception
    self.send_message({'command': 'error', 'msg': str(message)})
  File "pystorm/component.py", line 305, in send_message
    self.serializer.send_message(message)
  File "pystorm/serializers/serializer.py", line 26, in send_message
    self.output_stream.flush()
```

This should be a `StormWentAwayError`.  Will fix ASAP.
diff --git a/test/pystorm/serializers/test_json_serializer.py b/test/pystorm/serializers/test_json_serializer.py
index a18a9e8..f460f6e 100644
--- a/test/pystorm/serializers/test_json_serializer.py
+++ b/test/pystorm/serializers/test_json_serializer.py
@@ -7,7 +7,9 @@ except ImportError:
     import mock
 
 import simplejson as json
+import pytest
 
+from pystorm.exceptions import StormWentAwayError
 from pystorm.serializers.json_serializer import JSONSerializer
 
 from .serializer import SerializerTestCase
@@ -33,3 +35,12 @@ class TestJSONSerializer(SerializerTestCase):
         self.instance.output_stream = StringIO()
         self.instance.send_message(msg_dict)
         assert self.instance.output_stream.getvalue() == expected_output
+
+    def test_send_message_raises_stormwentaway(self):
+        string_io_mock = mock.MagicMock(autospec=True)
+        def raiser(): # lambdas can't raise
+            raise IOError()
+        string_io_mock.flush.side_effect = raiser
+        self.instance.output_stream = string_io_mock
+        with pytest.raises(StormWentAwayError):
+            self.instance.send_message({'hello': "world",})
diff --git a/test/pystorm/serializers/test_msgpack_serializer.py b/test/pystorm/serializers/test_msgpack_serializer.py
index e36a1ec..d51c19f 100644
--- a/test/pystorm/serializers/test_msgpack_serializer.py
+++ b/test/pystorm/serializers/test_msgpack_serializer.py
@@ -7,7 +7,9 @@ except ImportError:
     import mock
 
 import msgpack
+import pytest
 
+from pystorm.exceptions import StormWentAwayError
 from pystorm.serializers.msgpack_serializer import MsgpackSerializer
 
 from .serializer import SerializerTestCase
@@ -32,3 +34,12 @@ class TestMsgpackSerializer(SerializerTestCase):
         expected_output = msgpack.packb(msg_dict)
         self.instance.send_message(msg_dict)
         assert self.instance.output_stream.getvalue() == expected_output
+
+    def test_send_message_raises_stormwentaway(self):
+        bytes_io_mock = mock.MagicMock(autospec=True)
+        def raiser(): # lambdas can't raise
+            raise IOError()
+        bytes_io_mock.flush.side_effect = raiser
+        self.instance.output_stream = bytes_io_mock
+        with pytest.raises(StormWentAwayError):
+            self.instance.send_message({'hello': "world",})

pip install -e .[all]
parse_log_pytest
requirements.txt
apt-get update apt-get install -y gcc
3.5
requirements.txt
pytest --no-header -rA --tb=line --color=no -p no:cacheprovider -W ignore::DeprecationWarning
attrs==22.2.0
certifi==2021.5.30
importlib-metadata==4.8.3
iniconfig==1.1.1
msgpack-python==0.5.6
packaging==21.3
pluggy==1.0.0
py==1.11.0
pyparsing==3.1.4
-e git+https://github.com/pystorm/pystorm.git@ee14ec810de20d62929a418fff88285833b6afe5#egg=pystorm
pytest==7.0.1
pytest-timeout==2.1.0
simplejson==3.20.1
six==1.17.0
tomli==1.2.3
typing_extensions==4.1.1
zipp==3.6.0

name: pystorm
channels:
  - defaults
  - https://repo.anaconda.com/pkgs/main
  - https://repo.anaconda.com/pkgs/r
  - conda-forge
dependencies:
  - _libgcc_mutex=0.1=main
  - _openmp_mutex=5.1=1_gnu
  - ca-certificates=2025.2.25=h06a4308_0
  - certifi=2021.5.30=py36h06a4308_0
  - ld_impl_linux-64=2.40=h12ee557_0
  - libffi=3.3=he6710b0_2
  - libgcc-ng=11.2.0=h1234567_1
  - libgomp=11.2.0=h1234567_1
  - libstdcxx-ng=11.2.0=h1234567_1
  - ncurses=6.4=h6a678d5_0
  - openssl=1.1.1w=h7f8727e_0
  - pip=21.2.2=py36h06a4308_0
  - python=3.6.13=h12debd9_1
  - readline=8.2=h5eee18b_0
  - setuptools=58.0.4=py36h06a4308_0
  - sqlite=3.45.3=h5eee18b_0
  - tk=8.6.14=h39e8969_0
  - wheel=0.37.1=pyhd3eb1b0_0
  - xz=5.6.4=h5eee18b_1
  - zlib=1.2.13=h5eee18b_1
  - pip:
      - attrs==22.2.0
      - importlib-metadata==4.8.3
      - iniconfig==1.1.1
      - msgpack-python==0.5.6
      - packaging==21.3
      - pluggy==1.0.0
      - py==1.11.0
      - pyparsing==3.1.4
      - pytest==7.0.1
      - pytest-timeout==2.1.0
      - simplejson==3.20.1
      - six==1.17.0
      - tomli==1.2.3
      - typing-extensions==4.1.1
      - zipp==3.6.0
prefix: /opt/conda/envs/pystorm

test/pystorm/serializers/test_json_serializer.py::TestJSONSerializer::test_send_message_raises_stormwentaway test/pystorm/serializers/test_msgpack_serializer.py::TestMsgpackSerializer::test_send_message_raises_stormwentaway
test/pystorm/serializers/test_json_serializer.py::TestJSONSerializer::test_read_message_dict test/pystorm/serializers/test_json_serializer.py::TestJSONSerializer::test_read_message_list test/pystorm/serializers/test_json_serializer.py::TestJSONSerializer::test_send_message test/pystorm/serializers/test_msgpack_serializer.py::TestMsgpackSerializer::test_read_message_dict test/pystorm/serializers/test_msgpack_serializer.py::TestMsgpackSerializer::test_read_message_list test/pystorm/serializers/test_msgpack_serializer.py::TestMsgpackSerializer::test_send_message
pystorm/serializers/serializer.py
pystorm/serializers/serializer.py