share / share/sharedb

Middleware Errors Get Logged if instance of "Error" class

Open
#516 5 comments 0 reactions 0 assignees View on GitHub

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

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. 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

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.