                     cb   : (err, s) =>
                         socket = s; cb(err)
             (cb) =>
-                if opts.project
-                    opts.project._socket_id = socket.id
+                # record that this socket was used by the given project
+                # (so on close can invalidate info)
+                opts.project._socket_id = socket.id
                 socket.write_mesg 'json', opts.mesg, (err) =>
                     if err
                         cb("error writing to socket -- #{err}")

                            socket.on 'close', () =>
                                dbg("socket #{socket.id} closed")
                                for _, p of @_project_cache
                                    # tell every project whose state was set via a push event
                                    # from this socket that the state is no longer known.
                                    if p._socket_id == socket.id
                                        delete p._state
                                        delete p._state_time

            project_id : @project_id
            state      : @_state
            time       : @_state_time
        dbg("send message to each of the #{@_state_listeners.length} listeners that the state has been updated = #{misc.to_safe_str(mesg)}")
        for id, socket of @_state_listeners
            dbg("sending mesg to socket #{id}")
            socket.write_mesg('json', mesg)
