mirror of
https://gitlab.com/soapbox-pub/ditto.git
synced 2025-12-06 11:29:46 +00:00
try-catch the InternalRelay req's
This commit is contained in:
parent
7a18a19b2f
commit
7aa931a69e
4 changed files with 28 additions and 26 deletions
|
|
@ -16,7 +16,7 @@
|
||||||
"exclude": ["./public"],
|
"exclude": ["./public"],
|
||||||
"imports": {
|
"imports": {
|
||||||
"@/": "./src/",
|
"@/": "./src/",
|
||||||
"@nostrify/nostrify": "jsr:@nostrify/nostrify@^0.12.1",
|
"@nostrify/nostrify": "jsr:@nostrify/nostrify@^0.14.2",
|
||||||
"@std/cli": "jsr:@std/cli@^0.223.0",
|
"@std/cli": "jsr:@std/cli@^0.223.0",
|
||||||
"@std/json": "jsr:@std/json@^0.223.0",
|
"@std/json": "jsr:@std/json@^0.223.0",
|
||||||
"@std/streams": "jsr:@std/streams@^0.223.0",
|
"@std/streams": "jsr:@std/streams@^0.223.0",
|
||||||
|
|
|
||||||
|
|
@ -68,6 +68,7 @@ const streamingController: AppController = (c) => {
|
||||||
const filter = await topicToFilter(stream, c.req.query(), pubkey);
|
const filter = await topicToFilter(stream, c.req.query(), pubkey);
|
||||||
if (!filter) return;
|
if (!filter) return;
|
||||||
|
|
||||||
|
try {
|
||||||
for await (const msg of Storages.pubsub.req([filter], { signal: controller.signal })) {
|
for await (const msg of Storages.pubsub.req([filter], { signal: controller.signal })) {
|
||||||
if (msg[0] === 'EVENT') {
|
if (msg[0] === 'EVENT') {
|
||||||
const [event] = await hydrateEvents({
|
const [event] = await hydrateEvents({
|
||||||
|
|
@ -91,6 +92,9 @@ const streamingController: AppController = (c) => {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
} catch (e) {
|
||||||
|
debug('streaming error:', e);
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
socket.onclose = () => {
|
socket.onclose = () => {
|
||||||
|
|
|
||||||
|
|
@ -77,11 +77,15 @@ function connectStream(socket: WebSocket) {
|
||||||
|
|
||||||
send(['EOSE', subId]);
|
send(['EOSE', subId]);
|
||||||
|
|
||||||
|
try {
|
||||||
for await (const msg of Storages.pubsub.req(filters, { signal: controller.signal })) {
|
for await (const msg of Storages.pubsub.req(filters, { signal: controller.signal })) {
|
||||||
if (msg[0] === 'EVENT') {
|
if (msg[0] === 'EVENT') {
|
||||||
send(['EVENT', subId, msg[2]]);
|
send(['EVENT', subId, msg[2]]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
} catch (_e) {
|
||||||
|
controllers.delete(subId);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Handle EVENT. Store the event. */
|
/** Handle EVENT. Store the event. */
|
||||||
|
|
|
||||||
|
|
@ -18,12 +18,6 @@ type EventStub = TypeFest.SetOptional<EventTemplate, 'content' | 'created_at' |
|
||||||
|
|
||||||
/** Publish an event through the pipeline. */
|
/** Publish an event through the pipeline. */
|
||||||
async function createEvent(t: EventStub, c: AppContext): Promise<NostrEvent> {
|
async function createEvent(t: EventStub, c: AppContext): Promise<NostrEvent> {
|
||||||
const pubkey = c.get('pubkey');
|
|
||||||
|
|
||||||
if (!pubkey) {
|
|
||||||
throw new HTTPException(401);
|
|
||||||
}
|
|
||||||
|
|
||||||
const signer = new APISigner(c);
|
const signer = new APISigner(c);
|
||||||
|
|
||||||
const event = await signer.signEvent({
|
const event = await signer.signEvent({
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue