Skip to content

Commit

Permalink
chore(prisma): upgrade to prisma 5.3.1 (#1017)
Browse files Browse the repository at this point in the history
  • Loading branch information
steebchen authored Sep 28, 2023
1 parent ad27d83 commit 10bf2b3
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 19 deletions.
4 changes: 2 additions & 2 deletions binaries/binaries.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,11 @@ import (
)

// PrismaVersion is a hardcoded version of the Prisma CLI.
const PrismaVersion = "5.2.0"
const PrismaVersion = "5.3.1"

// EngineVersion is a hardcoded version of the Prisma Engine.
// The versions can be found under https://github.com/prisma/prisma-engines/commits/main
const EngineVersion = "2804dc98259d2ea960602aca6b8e7fdc03c1758f"
const EngineVersion = "61e140623197a131c2a6189271ffee05a7aa9a59"

// PrismaURL points to an S3 bucket URL where the CLI binaries are stored.
var PrismaURL = "https://packaged-cli.prisma.sh/%s-%s-%s-%s.gz"
Expand Down
2 changes: 2 additions & 0 deletions engine/do.go
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,8 @@ func request(ctx context.Context, client *http.Client, method string, url string
}

if logger.Enabled {
logger.Debug.Printf("prisma engine response: `%s`", responseBody)

if elapsedRaw := rawResponse.Header["X-Elapsed"]; len(elapsedRaw) > 0 {
elapsed, _ := strconv.Atoi(elapsedRaw[0])
duration := time.Duration(elapsed) * time.Microsecond
Expand Down
23 changes: 11 additions & 12 deletions engine/lifecycle.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import (
"os"
"os/exec"
"path"
"strconv"
"strings"
"time"

Expand Down Expand Up @@ -215,7 +216,6 @@ func (e *QueryEngine) spawn(file string) error {

// send a basic readiness healthcheck and retry if unsuccessful
var connectErr error
var gqlErrors []GQLError
for i := 0; i < 100; i++ {
body, err := e.Request(ctx, "GET", "/status", map[string]interface{}{}, false)
if err != nil {
Expand All @@ -225,34 +225,33 @@ func (e *QueryEngine) spawn(file string) error {
continue
}

var response GQLResponse
var response struct {
Status string `json:"status"`
}

if err := json.Unmarshal(body, &response); err != nil {
// the response is a JSON in a string, so unquote it
unquoted, _ := strconv.Unquote(string(body))
if err := json.Unmarshal([]byte(unquoted), &response); err != nil {
connectErr = err
logger.Debug.Printf("could not unmarshal response; retrying...")
logger.Debug.Printf("could not unmarshal response %s; retrying...", body)
time.Sleep(50 * time.Millisecond)
continue
}

if response.Errors != nil {
gqlErrors = response.Errors
logger.Debug.Printf("could not connect due to gql errors; retrying...")
if response.Status != "ok" {
connectErr = fmt.Errorf("unexpected status: " + response.Status)
logger.Debug.Printf("could not connect due to unexpected status %s ; retrying...", response.Status)
time.Sleep(50 * time.Millisecond)
continue
}

connectErr = nil
gqlErrors = nil
break
}

if connectErr != nil {
return fmt.Errorf("readiness query error: %w", connectErr)
}

if gqlErrors != nil {
return fmt.Errorf("readiness gql errors: %+v", gqlErrors)
}

return nil
}
5 changes: 0 additions & 5 deletions engine/request.go
Original file line number Diff line number Diff line change
Expand Up @@ -91,11 +91,6 @@ func (e *QueryEngine) Request(ctx context.Context, method string, path string, p
return nil, fmt.Errorf("payload marshal: %w", err)
}

// TODO use specific log level
if logger.Enabled {
logger.Debug.Printf("prisma engine payload: `%s`", requestBody)
}

return request(ctx, e.http, method, e.url+path, requestBody, func(req *http.Request) {
req.Header.Set("content-type", "application/json")
})
Expand Down

0 comments on commit 10bf2b3

Please sign in to comment.