{"id":28396357,"url":"https://github.com/ssbc/ssb-network-errors","last_synced_at":"2025-08-08T05:45:00.370Z","repository":{"id":57368792,"uuid":"378193600","full_name":"ssbc/ssb-network-errors","owner":"ssbc","description":" Classify muxrpc and SSB network errors by severity ","archived":false,"fork":false,"pushed_at":"2021-10-08T11:05:47.000Z","size":19,"stargazers_count":4,"open_issues_count":0,"forks_count":0,"subscribers_count":4,"default_branch":"main","last_synced_at":"2025-07-30T15:21:56.670Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/ssbc.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSES/CC0-1.0.txt","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2021-06-18T15:31:04.000Z","updated_at":"2022-05-13T20:14:51.000Z","dependencies_parsed_at":"2022-08-23T20:10:48.691Z","dependency_job_id":null,"html_url":"https://github.com/ssbc/ssb-network-errors","commit_stats":null,"previous_names":["ssb-ngi-pointer/ssb-network-errors"],"tags_count":6,"template":false,"template_full_name":null,"purl":"pkg:github/ssbc/ssb-network-errors","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ssbc%2Fssb-network-errors","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ssbc%2Fssb-network-errors/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ssbc%2Fssb-network-errors/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ssbc%2Fssb-network-errors/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/ssbc","download_url":"https://codeload.github.com/ssbc/ssb-network-errors/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ssbc%2Fssb-network-errors/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":269372797,"owners_count":24406274,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","status":"online","status_checked_at":"2025-08-08T02:00:09.200Z","response_time":72,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2025-05-31T21:38:12.933Z","updated_at":"2025-08-08T05:45:00.274Z","avatar_url":"https://github.com/ssbc.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"\u003c!--\nSPDX-FileCopyrightText: 2021 Andre Staltz\n\nSPDX-License-Identifier: CC0-1.0\n--\u003e\n\n# ssb-network-errors\n\n*Detect the severity of a muxrpc error or network connection error to a remote SSB peer.*\n\nMuxrpc and packet-stream throw specific errors when the stream terminates. In Node.js these errors have a specific message string. In go-ssb they have another specific message string. This module handles the pattern recognition of those error messages and classifies them with a severity level.\n\n\n## Usage\n\n```\nnpm install --save ssb-network-errors\n```\n\nThis module is just a function that takes a network error and classifies it with\na **severity number** ranging from 0 to 3.\n\n- **Severity 0**: the **local** peer (us) closed the muxrpc connection with the remote peer gracefully, there is nothing to handle here\n- **Severity 1**: the **remote** peer (them) closed the muxrpc connection with us, we MAY have to close or clean up connection details\n- **Severity 2**: a network error such as TCP or secret-handshake related occurred, may indicate a problem with the user's internet connectivity or authentication issues (related to secret-handshake)\n- **Severity 3**: any other kind of error that this module cannot classify is labelled with severity 3\n\n```js\nconst getSeverity = require('ssb-network-errors')\nconst pull = require('pull-stream')\n\n// rpc is connection to a remote SSB peer\npull(\n  rpc.createHistoryStream({ id })\n  ssb.createWriteStream((err) =\u003e {\n    const severity = getSeverity(err)\n    if (severity === 0) {\n      console.log('we closed the local stream')\n      console.log('more details:', err)\n    }\n    else if (severity === 1) {\n      console.log('THEY closed the local stream')\n      console.log('more details:', err)\n    }\n    else if (severity === 2) {\n      console.log('a typical TCP or internet error occurred')\n      console.log('more details:', err)\n    }\n    else if (severity === 3) {\n      console.log('something truly unexpected happened to the connection')\n      console.log('more details:', err)\n    }\n  })\n)\n```\n\n## License\n\nLGPL-3.0\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fssbc%2Fssb-network-errors","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fssbc%2Fssb-network-errors","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fssbc%2Fssb-network-errors/lists"}