From 88b1fd60b64eca6214d8e6b2184970f47110185f Mon Sep 17 00:00:00 2001 From: Justin Baker Date: Fri, 31 Aug 2018 14:55:06 -0500 Subject: [PATCH] Fix a race condition a socket would closed before a task started --- test/websockex_test.exs | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/test/websockex_test.exs b/test/websockex_test.exs index 813a4bc..6548d46 100644 --- a/test/websockex_test.exs +++ b/test/websockex_test.exs @@ -605,11 +605,16 @@ defmodule WebSockexTest do # Really glad that I got those sys behaviors now :sys.suspend(pid) + test_pid = self() + task = Task.async(fn -> + send(test_pid, :task_started) WebSockex.send_frame(pid, {:text, "hello"}) end) + assert_receive :task_started + :gen_tcp.shutdown(conn.socket, :write) :sys.resume(pid)