Skip to content

Commit

Permalink
fix: duplicate WriteHeader call
Browse files Browse the repository at this point in the history
  • Loading branch information
gernest committed Mar 2, 2024
1 parent 32be121 commit ad93080
Show file tree
Hide file tree
Showing 4 changed files with 4 additions and 2 deletions.
1 change: 1 addition & 0 deletions internal/cluster/http/service.go
Original file line number Diff line number Diff line change
Expand Up @@ -498,6 +498,7 @@ func (s *Service) process(w http.ResponseWriter, r *http.Request, e *v1.Data) {
err := s.store.Data(ctx, e)
if err == nil {
w.WriteHeader(http.StatusAccepted)
return
}
if !errors.Is(err, store.ErrNotLeader) {
s.log.Error("failed to store event data", "err", err)
Expand Down
1 change: 1 addition & 0 deletions internal/cluster/store/store.go
Original file line number Diff line number Diff line change
Expand Up @@ -236,6 +236,7 @@ var _ Storage = (*Store)(nil)

func NewStore(base *v1.Config, transit raft.Transport, mgr *connections.Manager, tenants *tenant.Tenants) (*Store, error) {
dbPath := filepath.Join(base.Data, dbName)
os.RemoveAll(dbPath) // rely on raft to keep this up to date
store, err := db.NewKV(dbPath)
if err != nil {
return nil, err
Expand Down
2 changes: 1 addition & 1 deletion internal/load/load.go
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,7 @@ func (s *Session) send(name, path string, dump bool) error {
return err
}
defer res.Body.Close()
if res.StatusCode != http.StatusOK {
if res.StatusCode != http.StatusAccepted {
data, _ = io.ReadAll(res.Body)
return errors.New(string(data))
}
Expand Down
2 changes: 1 addition & 1 deletion internal/load/testdata/page_view.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
const site = "https://vinceanalytics.com"
for (let index = 0; index < limit; index++) {
const session = createSession(site);
session.SendDebug("pageview", "/");
session.Send("pageview", "/");
}

0 comments on commit ad93080

Please sign in to comment.