mirror of
https://github.com/matrix-org/dendrite.git
synced 2025-12-17 03:43:11 -06:00
Don't 500 on context errors
This commit is contained in:
parent
22d9e177a4
commit
49c3f43cf1
|
|
@ -105,7 +105,7 @@ type txnFederationClient interface {
|
||||||
GetEvent(ctx context.Context, s gomatrixserverlib.ServerName, eventID string) (res gomatrixserverlib.Transaction, err error)
|
GetEvent(ctx context.Context, s gomatrixserverlib.ServerName, eventID string) (res gomatrixserverlib.Transaction, err error)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (t *txnReq) processTransaction() *gomatrixserverlib.RespSend {
|
func (t *txnReq) processTransaction() (*gomatrixserverlib.RespSend, error) {
|
||||||
results := make(map[string]gomatrixserverlib.PDUResult)
|
results := make(map[string]gomatrixserverlib.PDUResult)
|
||||||
|
|
||||||
var pdus []gomatrixserverlib.HeaderedEvent
|
var pdus []gomatrixserverlib.HeaderedEvent
|
||||||
|
|
@ -160,16 +160,18 @@ func (t *txnReq) processTransaction() *gomatrixserverlib.RespSend {
|
||||||
// receive another event referencing it.
|
// receive another event referencing it.
|
||||||
// If we bail and stop processing then we risk wedging incoming
|
// If we bail and stop processing then we risk wedging incoming
|
||||||
// transactions from that server forever.
|
// transactions from that server forever.
|
||||||
/*
|
switch err.(type) {
|
||||||
switch err.(type) {
|
case roomNotFoundError:
|
||||||
case roomNotFoundError:
|
case *gomatrixserverlib.NotAllowed:
|
||||||
case *gomatrixserverlib.NotAllowed:
|
default:
|
||||||
default:
|
// We shouldn't return 500s in response to an expired context.
|
||||||
// Any other error should be the result of a temporary error in
|
if err == context.Canceled || err == context.DeadlineExceeded {
|
||||||
// our server so we should bail processing the transaction entirely.
|
break
|
||||||
return nil, err
|
|
||||||
}
|
}
|
||||||
*/
|
// Any other error should be the result of a temporary error in
|
||||||
|
// our server so we should bail processing the transaction entirely.
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
results[e.EventID()] = gomatrixserverlib.PDUResult{
|
results[e.EventID()] = gomatrixserverlib.PDUResult{
|
||||||
Error: err.Error(),
|
Error: err.Error(),
|
||||||
}
|
}
|
||||||
|
|
@ -181,7 +183,7 @@ func (t *txnReq) processTransaction() *gomatrixserverlib.RespSend {
|
||||||
|
|
||||||
t.processEDUs(t.EDUs)
|
t.processEDUs(t.EDUs)
|
||||||
util.GetLogger(t.context).Infof("Processed %d PDUs from transaction %q", len(results), t.TransactionID)
|
util.GetLogger(t.context).Infof("Processed %d PDUs from transaction %q", len(results), t.TransactionID)
|
||||||
return &gomatrixserverlib.RespSend{PDUs: results}
|
return &gomatrixserverlib.RespSend{PDUs: results}, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
type roomNotFoundError struct {
|
type roomNotFoundError struct {
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue