Handle socket errors
This commit is contained in:
@@ -0,0 +1,5 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
|
||||||
|
for package in $(ls packages); do
|
||||||
|
./build_and_link.sh $package
|
||||||
|
done
|
||||||
Generated
+2
-2
@@ -3059,7 +3059,7 @@
|
|||||||
},
|
},
|
||||||
"packages/feeds": {
|
"packages/feeds": {
|
||||||
"name": "@welshman/feeds",
|
"name": "@welshman/feeds",
|
||||||
"version": "0.0.6",
|
"version": "0.0.7",
|
||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@welshman/util": "0.0.9"
|
"@welshman/util": "0.0.9"
|
||||||
@@ -3096,7 +3096,7 @@
|
|||||||
},
|
},
|
||||||
"packages/net": {
|
"packages/net": {
|
||||||
"name": "@welshman/net",
|
"name": "@welshman/net",
|
||||||
"version": "0.0.8",
|
"version": "0.0.9",
|
||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@welshman/lib": "0.0.6",
|
"@welshman/lib": "0.0.6",
|
||||||
|
|||||||
@@ -230,7 +230,6 @@ export class FeedCompiler<E extends TrustedEvent> {
|
|||||||
|
|
||||||
if (event) {
|
if (event) {
|
||||||
for (const feed of feedsFromTags(Tags.fromEvent(event), mappings)) {
|
for (const feed of feedsFromTags(Tags.fromEvent(event), mappings)) {
|
||||||
|
|
||||||
feeds.push(feed)
|
feeds.push(feed)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "@welshman/feeds",
|
"name": "@welshman/feeds",
|
||||||
"version": "0.0.6",
|
"version": "0.0.7",
|
||||||
"author": "hodlbod",
|
"author": "hodlbod",
|
||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
"description": "Utilities for building dynamic nostr feeds.",
|
"description": "Utilities for building dynamic nostr feeds.",
|
||||||
|
|||||||
@@ -159,12 +159,11 @@ export class ConnectionMeta {
|
|||||||
getSpeed = () => this.responseCount ? this.responseTimer / this.responseCount : 0
|
getSpeed = () => this.responseCount ? this.responseTimer / this.responseCount : 0
|
||||||
|
|
||||||
getStatus = () => {
|
getStatus = () => {
|
||||||
if (this.authStatus === AuthStatus.Unauthorized) return ConnectionStatus.Unauthorized
|
if (this.authStatus === AuthStatus.Unauthorized) return ConnectionStatus.Unauthorized
|
||||||
if (this.authStatus === AuthStatus.Forbidden) return ConnectionStatus.Forbidden
|
if (this.authStatus === AuthStatus.Forbidden) return ConnectionStatus.Forbidden
|
||||||
if (this.lastOpen === 0) return ConnectionStatus.Closed
|
if (this.lastFault && this.lastFault > this.lastOpen) return ConnectionStatus.Error
|
||||||
if (this.lastFault > this.lastOpen) return ConnectionStatus.Error
|
if (this.lastClose > this.lastOpen) return ConnectionStatus.Closed
|
||||||
if (this.lastClose > this.lastOpen) return ConnectionStatus.Closed
|
if (this.getSpeed() > 1000) return ConnectionStatus.Slow
|
||||||
if (this.getSpeed() > 1000) return ConnectionStatus.Slow
|
|
||||||
|
|
||||||
return ConnectionStatus.Ok
|
return ConnectionStatus.Ok
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -59,6 +59,7 @@ export class Socket {
|
|||||||
}
|
}
|
||||||
|
|
||||||
onError = () => {
|
onError = () => {
|
||||||
|
this.failedToConnect = true
|
||||||
this.opts.onError()
|
this.opts.onError()
|
||||||
this.disconnect()
|
this.disconnect()
|
||||||
}
|
}
|
||||||
@@ -105,7 +106,7 @@ export class Socket {
|
|||||||
if (this.ws) {
|
if (this.ws) {
|
||||||
const currentWs = this.ws
|
const currentWs = this.ws
|
||||||
|
|
||||||
this.ready.then(() => currentWs.close())
|
this.ready.finally(() => currentWs.close())
|
||||||
this.ready = defer()
|
this.ready = defer()
|
||||||
this.opts.onClose()
|
this.opts.onClose()
|
||||||
this.ws = undefined
|
this.ws = undefined
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "@welshman/net",
|
"name": "@welshman/net",
|
||||||
"version": "0.0.8",
|
"version": "0.0.9",
|
||||||
"author": "hodlbod",
|
"author": "hodlbod",
|
||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
"description": "Utilities for connecting with nostr relays.",
|
"description": "Utilities for connecting with nostr relays.",
|
||||||
|
|||||||
@@ -1,7 +1,8 @@
|
|||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
|
|
||||||
|
./build.sh
|
||||||
|
|
||||||
for package in $(ls packages); do
|
for package in $(ls packages); do
|
||||||
./build_and_link.sh $package
|
|
||||||
npx onchange packages/$package -e '**/build/**' -k -- ./build_and_link.sh $package &
|
npx onchange packages/$package -e '**/build/**' -k -- ./build_and_link.sh $package &
|
||||||
done
|
done
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user