taosdata / driver-go

taos go driver
MIT License
88 stars 33 forks source link

The schemaless client doesn't check for errors before using the WebSocket client which may be nil. #279

Closed virtyaluk closed 1 month ago

virtyaluk commented 3 months ago

As the title says the Schemaless client doesn't check for WebSocket client errors before using it. It does, but only further in the code:

    ws, _, err := dialer.Dial(wsUrl.String(), nil)
    ws.EnableWriteCompression(config.enableCompression)
    if err != nil {
        return nil, fmt.Errorf("dial ws error: %s", err)
    }

Suppose your TDEngine instance is down or unreachable for any reason. In that case, the schemaless client code will panic, making the client library unusable in production-like environments where the DB instance may be down for many reasons.

It is a basic Go code practice to check for returned errors to catch any abnormal behavior and these things should be carefully tested before going into production.

Thanks.