Conversation
…ket in order to shut down properly Co-authored-by: t6d <konstantin@tennhard.net>
Co-authored-by: t6d <konstantin@tennhard.net>
…lled - Ensure that the close code and message is sent correctly when close is intiated by the client - Update the websocket tests to verify that notifications are not sent to closed connections
…tered otherwise we might get a channel close error if api.Notify is called during the shut down
@@ -140,4 +177,11 @@ type extensionsResponse struct { | |||
Version string `json:"version"` | |||
} | |||
|
|||
type client struct { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not for this PR, but I think we should explore if client
could wrap the connection and manage access to it. I'm thinking of
func newClient(conn *websocket.Conn, MessageHandler) *client {
client := client{...}
go client.receive()
return &client
}
func (c *client) send(update StatusUpdate) {}
func (c *receive)
func (c *client) close()
type MessageHandler func(msg interface{})
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I made a follow up issue #90
server := &http.Server{Addr: addr, Handler: api} | ||
|
||
onInterrupt(func() { | ||
api.Shutdown() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In future, we should pass a ctx with a deadline here as well. The shutdown should then be done as follows:
- Attempt graceful shutdown and wait until all connections have been closed
- Wait no longer than the deadline on the context permits
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What would be set for the context deadline?
Fix #70
Tophat
Run
make bootstrap; make build
to set upClient close connection
./shopify-extensions serve < testdata/shopifile.yml
1000
, the reason set to"done"
andwasClean = true
Server shut down
./shopify-extensions serve < testdata/shopifile.yml
panic: send on closed channel
thrown but this is not related to the websocket shutting down. We are currently not handling interrupts in the code tomonitor
so it tries to send a build error notification. This can be cleaned up in a later PR.1000
, the reason set to"server shut down"
andwasClean = true