You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.md
+79Lines changed: 79 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -662,3 +662,82 @@ ShareDB returns errors as plain JavaScript objects with the format:
662
662
```
663
663
664
664
Additional fields may be added to the error object for debugging context depending on the error. Common additional fields include `collection`, `id`, and `op`.
665
+
666
+
### Common error codes
667
+
668
+
#### `ERR_OP_SUBMIT_REJECTED`
669
+
670
+
The op submitted by the client has been rejected by the server for a non-critical reason.
671
+
672
+
When the client receives this code, it will attempt to roll back the rejected op, leaving the client in a usable state.
673
+
674
+
This error might be used as part of standard control flow. For example, consumers may define a middleware that validates document structure, and rejects operations that do not conform to this schema using this error code to reset the client to a valid state.
675
+
676
+
#### `ERR_OP_ALREADY_SUBMITTED`
677
+
678
+
The same op has been received by the server twice.
679
+
680
+
This is non-critical, and part of normal control flow, and is sent as an error in order to short-circuit the op processing. It is eventually swallowed by the server, and shouldn't need further handling.
681
+
682
+
#### `ERR_SUBMIT_TRANSFORM_OPS_NOT_FOUND`
683
+
684
+
The ops needed to transform the submitted op up to the current version of the snapshot could not be found.
685
+
686
+
If a client on an old version of a document submits an op, that op needs to be transformed by all the ops that have been applied to the document in the meantime. If the server cannot fetch these ops from the database, then this error is returned.
687
+
688
+
The most common case of this would be ops being deleted from the database. For example, let's assume we have a TTL set up on the ops in our database. Let's also say we have a client that is so old that the op corresponding to its version has been deleted by the TTL policy. If this client then attempts to submit an op, the server will not be able to find the ops required to transform the op to apply to the current version of the snapshot.
689
+
690
+
Other causes of this error may be dropping the ops collection all together, or having the database corrupted in some other way.
691
+
692
+
#### `ERR_MAX_SUBMIT_RETRIES_EXCEEDED`
693
+
694
+
The number of retries defined by the `maxSubmitRetries` option has been exceeded by a submission.
695
+
696
+
#### `ERR_DOC_ALREADY_CREATED`
697
+
698
+
The creation request has failed, because the document was already created by another client.
699
+
700
+
This can happen when two clients happen to simultaneously try to create the same document, and is potentially recoverable by simply fetching the already-created document.
701
+
702
+
#### `ERR_DOC_ALREADY_DELETED`
703
+
704
+
The deletion request has failed, because the document was already deleted by another client.
705
+
706
+
This can happen when two clients happen to simultaneously try to delete the same document. Given that the end result is the same, this error can potentially just be ignored.
707
+
708
+
#### `ERR_DOC_TYPE_NOT_RECOGNIZED`
709
+
710
+
The specified document type has not been registered with ShareDB.
711
+
712
+
This error can usually be remedied by remembering to register any types you need:
713
+
714
+
```javascript
715
+
var ShareDB =require('sharedb');
716
+
var richText =require('rich-text');
717
+
718
+
ShareDB.types.register(richText.type);
719
+
```
720
+
721
+
#### `ERR_DEFAULT_TYPE_MISMATCH`
722
+
723
+
The default type being used by the client does not match the default type expected by the server.
724
+
725
+
This will typically only happen when using a different default type to the built-in `json0` used by ShareDB by default (eg if using a fork). The exact same type must be used by both the client and the server, and should be registered as the default type:
726
+
727
+
```javascript
728
+
var ShareDB =require('sharedb');
729
+
var forkedJson0 =require('forked-json0');
730
+
731
+
// Make sure to also do this on your client
732
+
ShareDB.types.defaultType=forkedJson0.type;
733
+
```
734
+
735
+
#### `ERR_OP_NOT_ALLOWED_IN_PROJECTION`
736
+
737
+
The submitted op is not valid when applied to the projection.
738
+
739
+
This may happen if the op targets some property that is not included in the projection.
740
+
741
+
#### `ERR_TYPE_CANNOT_BE_PROJECTED`
742
+
743
+
The document's type cannot be projected. `json0` is currently the only type that supports projections.
0 commit comments