Skip to content
This repository was archived by the owner on Feb 12, 2024. It is now read-only.

Taking control of Error Handling, reducing js-ipfs Daemon crashes #1406

@fsdiogo

Description

@fsdiogo

Hey everyone, this issue has the purpose of gathering everything related to the js-ipfs daemon crashes and error handling.

Right now the daemon is unstable, there are a lot of uncaught exceptions and they crash the process when an error occurs down the stack.

There is a lot of work to be done around the robustness of the daemon and gateway, so this will serve as a roadmap to the state of each problem.

Roadmap

The related issues will be tracked using the table below.

Each one of them will have a priority, the same as our labels, from P0 - Critical to P4 - Very Low.

If possible, instructions of how to manually reproduce the error/crash and then tests to cause those errors, so we can track down the problem and start working on it.

When that problem is solved we'll link the solution or PR here, and mark the Status column as solved.

Issue Description Priority Manual Reproduction Test Reproduction Fix Status
#1326 WebSocket connection error P1
#1325 #1156 Already piped P1 #1458
#1331 Invalid block P2 #1378

Improving debuggability

We should strive to make debugging as smooth as possible.

Using debug to log meaningful events, namespacing the module you are on, is super helpful. It's easier to track logs and check the specific module that is writing them.

debug

Usage is pretty straightforward too:

const debug = require('debug')
const log = debug('libp2p:switch')

log('adding WebsocketStar')

For more info, check the usage section.

Improving error handling

We should use error codes like Node does.

Check this article for reference.

❌ This is bad:

const err = new Error('some error message')

// ... 

if (err.message.match(/some error message/)) {
  // do something
}

✅ This is good:

const ERRORS = require('./errors')

const err = Object.assign(new Error('some error message'), {
  code: ERRORS.ERR_SOME_ERROR_CODE,
  path: node._repo.path
})

// ...

if (err.code === 'ERR_SOME_ERROR_CODE') {
  // do something
}

Contribute

You can help move things forward by reporting issues and being diligent on how to reproduce the errors. After opening an issue, if you think it's fit for being here, comment providing the link and I'll add it to the table.

Also, feel free to dig in and try to tackle some of them, help is appreciated 🙂

Reference

Metadata

Metadata

Assignees

Labels

P0Critical: Tackled by core team ASAPawesome endeavourexp/wizardExtensive knowledge (implications, ramifications) requiredstatus/readyReady to be worked

Type

No type

Projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions