Middleware Errors Get Logged if instance of "Error" class
Nobody has claimed this yet.
- Dominant language
- JavaScript
- Stars
- 6.5k
- Forks
- 456
- Avg merge
- 1d 5h
- Merged PRs (30d)
- 5
Description
There appears to be an undesirable logging of a middleware error if it is an instance of an Error object.
Minimal reproduction (RunKit):
const ShareDB = require('sharedb');
const backend = new ShareDB();
backend.use('readSnapshots', (request, callback) => {
// This is fine - nothing gets logged (expected behavior):
// callback('Some error');
// This is not fine - the error gets logged (unexpected behavior).
callback(new Error('Some error'));
});
const connection = backend.connect();
const doc = connection.get('test', '123');
doc.fetch((error) => {
// Nothing being logged here!
//if (error) console.error(error);
//console.log('doc fetched');
});
The docs are not clear here in terms of what kind of object one can pass in as error.
https://share.github.io/sharedb/middleware/registration
Should it be an instance of Error? Or should it be a string? Or an object that's not an Error?
At the very least, I would suggest to update the documentation page to note that if you do pass an instance of Error, it will be logged to the console and there is no way to stop this logging from happening.
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start with the minimal reproduction in the issue and read the middleware registration documentation at share.github.io/sharedb/middleware/registration. Determine the intended error argument contract and where an Error instance is logged. Done means the behavior is clarified or corrected and the documentation accurately explains which error values are supported and whether logging occurs.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- javascript
- Domain
- backend, documentation
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100