1 Commits
Author SHA1 Message Date
sneak d33ae3013e Write a form-error page's status only after it renders (closes #128)
check / check (push) Failing after 1m4s
The login form and the webhook create and edit forms set their 400 or
409 with WriteHeader before calling renderTemplate, so a template
failure there answered with that status instead of 500. A variant of
renderTemplate now takes the status and writes it only once the page
has rendered into the buffer; renderTemplate sends 200 through it.

Model: opus-5-5
2026-10-02 12:00:32 +00:00
3 changed files with 12 additions and 17 deletions

No files matched your search

-5
View File
@@ -181,11 +181,6 @@ func (r *recordingArchives) Renames() []archiveRename {
return out return out
} }
// newTestApp returns an app whose RequireStart fails the test when
// starting takes longer than fx's default start timeout of 15s. That
// limit catches a start that hangs, not a busy host: measured with make
// test on 2026-10-02 at host load 58-69 on 48 cores, the slowest of this
// package's starts took 0.49s.
func newTestApp( func newTestApp(
t *testing.T, t *testing.T,
targets ...any, targets ...any,
+9 -3
View File
@@ -644,7 +644,9 @@ func (h *Handlers) applyWebhookEdit(
tmplKeyError: "Name is required", tmplKeyError: "Name is required",
} }
h.renderTemplateStatus(w, r, "source_edit.html", data, http.StatusBadRequest) h.renderTemplateStatus(
w, r, "source_edit.html", data, http.StatusBadRequest,
)
return return
} }
@@ -664,7 +666,9 @@ func (h *Handlers) applyWebhookEdit(
tmplKeyError: retentionErrorMessage(retErr), tmplKeyError: retentionErrorMessage(retErr),
} }
h.renderTemplateStatus(w, r, "source_edit.html", data, http.StatusBadRequest) h.renderTemplateStatus(
w, r, "source_edit.html", data, http.StatusBadRequest,
)
return return
} }
@@ -701,7 +705,9 @@ func (h *Handlers) applyWebhookEdit(
"it, then save again.", "it, then save again.",
} }
h.renderTemplateStatus(w, r, "source_edit.html", data, http.StatusConflict) h.renderTemplateStatus(
w, r, "source_edit.html", data, http.StatusConflict,
)
return return
} }
+3 -9
View File
@@ -2,10 +2,9 @@
# script/test: run the test suite. # script/test: run the test suite.
# #
# -timeout is applied by `go test` per package, not to the run as a whole, so # -timeout is applied by `go test` per package, not to the run as a whole, so
# it only has to clear the slowest single package. When this budget was set # it only has to clear the slowest single package. That is internal/handlers,
# that was internal/handlers, measured in a cache-defeated builder stage on the # measured in a cache-defeated builder stage on the 48-core shared build host
# 48-core shared build host (2026-08-18); load- and host-dependent, not # (2026-08-18); load- and host-dependent, not invariants:
# invariants:
# #
# 16.9s host load 5-20, GOMAXPROCS 48 # 16.9s host load 5-20, GOMAXPROCS 48
# 45.9s / 47.3s / 49.0s three runs at deliberate host load 31-73 # 45.9s / 47.3s / 49.0s three runs at deliberate host load 31-73
@@ -24,11 +23,6 @@
# a condition CI runs under. If a CPU-limited runner ever puts a real run near # a condition CI runs under. If a CPU-limited runner ever puts a real run near
# 67s, that is the datum to revisit the org figure with. # 67s, that is the datum to revisit the org figure with.
# #
# Those figures predate tests hashing the admin password at 1 MB instead of
# 64 MB (https://git.eeqj.de/sneak/webhooker/pulls/404). After that change, in
# a cache-defeated build at host load 44-109 (2026-10-02), internal/handlers
# took 8.5s and the slowest package was internal/database at 15.8s.
#
# -p 4 -parallel 8 keep the run under 2 GB of memory: at most four test # -p 4 -parallel 8 keep the run under 2 GB of memory: at most four test
# binaries build or run at once, each with at most eight parallel tests. Under # binaries build or run at once, each with at most eight parallel tests. Under
# -race every test binary and every link costs a few hundred MB, so the # -race every test binary and every link costs a few hundred MB, so the