Skip to content

Open-source status page, incident response and uptime monitoring

🔥 golang improvments (#992)

Thibault Le Ouaycc4dba94eb8f
diff --git a/.vscode/settings.json b/.vscode/settings.json
index fd6286385..4d9b67c52 100644
--- a/.vscode/settings.json
+++ b/.vscode/settings.json
@@ -21,5 +21,12 @@
},
"[ignore]": {
"editor.defaultFormatter": "foxundermoon.shell-format"
+ },
+ "go.lintTool": "golangci-lint",
+ "go.lintFlags": ["--fast"],
+ "gopls": {
+ "ui.diagnostic.analyses": {
+ "fieldalignment": true
+ }
}
}
diff --git a/apps/checker/cmd/main.go b/apps/checker/cmd/main.go
index be5f9bedd..121c61195 100644
--- a/apps/checker/cmd/main.go
+++ b/apps/checker/cmd/main.go
@@ -309,7 +309,7 @@ func main() {
headersAsString, err := json.Marshal(r.Headers)
if err != nil {
- return nil
+ return err
}
tbData := PingResponse{
diff --git a/apps/checker/update.go b/apps/checker/update.go
index b9ac983a6..b6e7ce8cb 100644
--- a/apps/checker/update.go
+++ b/apps/checker/update.go
@@ -24,14 +24,18 @@ func UpdateStatus(ctx context.Context, updateData UpdateData) {
url := "https://openstatus-api.fly.dev/updateStatus"
basic := "Basic " + os.Getenv("CRON_SECRET")
payloadBuf := new(bytes.Buffer)
- json.NewEncoder(payloadBuf).Encode(updateData)
- req, err := http.NewRequestWithContext(ctx, http.MethodPost, url, payloadBuf)
+ if err := json.NewEncoder(payloadBuf).Encode(updateData); err != nil {
+ log.Ctx(ctx).Error().Err(err).Msg("error while updating status")
+ return
+ }
+ req, _ := http.NewRequestWithContext(ctx, http.MethodPost, url, payloadBuf)
req.Header.Set("Authorization", basic)
req.Header.Set("Content-Type", "application/json")
client := &http.Client{Timeout: time.Second * 10}
- if _, err = client.Do(req); err != nil {
+ if _, err := client.Do(req); err != nil {
log.Ctx(ctx).Error().Err(err).Msg("error while updating status")
}
+ defer req.Body.Close()
// Should we add a retry mechanism here?
}
diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml
index 9ca19a8a9..6463fb778 100644
--- a/pnpm-lock.yaml
+++ b/pnpm-lock.yaml
@@ -7180,6 +7180,7 @@ packages:
resolution: {integrity: sha512-k92I/b08q4wvFscXCLvqfsHCrjrF7yiXsQuIVvVE7N82W3+aqpzuUdBbfhWcy/FZR3/4IgflMgKLOsvPDrGCJA==}
+ deprecated: This module is not supported, and leaks memory. Do not use it. Check out lru-cache if you want a good and tested way to coalesce async requests by a key value, which is much more comprehensive and powerful.
resolution: {integrity: sha512-k/vGaX4/Yla3WzyMCvTQOXYeIHvqOKtnqBduzTHpzpQZzAskKMhZ2K+EnBiSM9zGSoIFeMpXKxa4dYeZIQqewQ==}
@@ -9130,6 +9131,7 @@ packages:
resolution: {integrity: sha512-JZkJMZkAGFFPP2YqXZXPbMlMBgsxzE8ILs4lMIX/2o0L9UBw9O/Y3o6wFw/i9YLapcUJWwqbi3kdxIPdC62TIA==}
+ deprecated: Rimraf versions prior to v4 are no longer supported
hasBin: true
diff --git a/turbo.json b/turbo.json
index 60d737001..c8f37647e 100644
--- a/turbo.json
+++ b/turbo.json
@@ -11,7 +11,14 @@
"DATABASE_URL",
"TINY_BIRD_API_KEY",
"NODE_ENV",
- "VERCEL_URL"
+ "VERCEL_URL",
+ "TEAM_ID_VERCEL",
+ "PROJECT_ID_VERCEL",
+ "STRIPE_SECRET_KEY",
+ "UNKEY_TOKEN",
+ "UNKEY_API_ID",
+ "UPSTASH_REDIS_REST_URL",
+ "UPSTASH_REDIS_REST_TOKEN"
],
"outputs": [".next/**", "!.next/cache/**"]
},