@@ -105,8 +105,8 @@ function open_subscription(fn::Function,
105105 " payload" => payload
106106 )
107107 message_str = JSON3. write (message)
108-
109- HTTP. WebSockets. open (client. ws_endpoint; retry= retry, headers= client. headers) do ws
108+ throw_if_assigned = Ref {GraphQLClientException} ()
109+ HTTP. WebSockets. open (client. ws_endpoint; retry= retry, headers= client. headers, suppress_close_error = false ) do ws
110110 # Start sub
111111 output_info (verbose) && println (" Starting $(get_name (subscription_name)) subscription with ID $sub_id " )
112112 writews (ws, message_str)
@@ -132,11 +132,13 @@ function open_subscription(fn::Function,
132132 output_info (verbose) && println (" Subscription $sub_id stopped by the stop function supplied" )
133133 break
134134 end
135- response = JSON3. read (data:: Vector{UInt8} , GQLSubscriptionResponse{output_type})
135+ # Dropping typeassert as this may be string
136+ response = JSON3. read (data, GQLSubscriptionResponse{output_type})
136137 payload = response. payload
137138 if ! isnothing (payload. errors) && ! isempty (payload. errors) && throw_on_execution_error
138139 subscription_tracker[][sub_id] = " errored"
139- throw (GraphQLError (" Error during subscription." , payload))
140+ throw_if_assigned[] = GraphQLError (" Error during subscription." , payload)
141+ break
140142 end
141143 # Handle multiple subs, do we need this?
142144 if response. id == string (sub_id)
@@ -149,6 +151,8 @@ function open_subscription(fn::Function,
149151 end
150152 end
151153 end
154+ # We can't throw errors from the ws handle function in HTTP 1.0, as they get digested.
155+ isassigned (throw_if_assigned) && throw (throw_if_assigned[])
152156 output_debug (verbose) && println (" Finished. Closing subscription" )
153157 subscription_tracker[][sub_id] = " closed"
154158 return
0 commit comments