Skip to content

Commit b381e38

Browse files
committed
Merge tag '0.5.2' into 0.6-maintenance
Fedify 0.5.2
2 parents 5d68fa3 + 9e6eab8 commit b381e38

File tree

2 files changed

+24
-1
lines changed

2 files changed

+24
-1
lines changed

CHANGES.md

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,9 @@ Version 0.6.1
88

99
To be released.
1010

11+
- Fixed a bug of `new Federation()` constructor that if it is once called
12+
the process will never exit. [[#39]]
13+
1114

1215
Version 0.6.0
1316
-------------
@@ -53,6 +56,17 @@ Released on April 9, 2024.
5356
[#27]: https://github.com/dahlia/fedify/issues/27
5457

5558

59+
Version 0.5.2
60+
-------------
61+
62+
Released on April 17, 2024.
63+
64+
- Fixed a bug of `new Federation()` constructor that if it is once called
65+
the process will never exit. [[#39]]
66+
67+
[#39]: https://github.com/dahlia/fedify/issues/39
68+
69+
5670
Version 0.5.1
5771
-------------
5872

federation/middleware.ts

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -128,6 +128,7 @@ export class Federation<TContextData> {
128128
#kv: KvStore;
129129
#kvPrefixes: FederationKvPrefixes;
130130
#queue?: MessageQueue;
131+
#queueStarted: boolean;
131132
#router: Router;
132133
#nodeInfoDispatcher?: NodeInfoDispatcher<TContextData>;
133134
#actorCallbacks?: ActorCallbacks<TContextData>;
@@ -170,6 +171,7 @@ export class Federation<TContextData> {
170171
...(kvPrefixes ?? {}),
171172
};
172173
this.#queue = queue;
174+
this.#queueStarted = false;
173175
this.#router = new Router();
174176
this.#router.add("/.well-known/webfinger", "webfinger");
175177
this.#router.add("/.well-known/nodeinfo", "nodeInfoJrd");
@@ -191,8 +193,13 @@ export class Federation<TContextData> {
191193
15 * 60_000,
192194
60 * 60_000,
193195
].map((ms) => Temporal.Duration.from({ milliseconds: ms }));
196+
}
194197

195-
queue?.listen(this.#listenQueue.bind(this));
198+
#startQueue() {
199+
if (this.#queue != null && !this.#queueStarted) {
200+
this.#queue?.listen(this.#listenQueue.bind(this));
201+
this.#queueStarted = true;
202+
}
196203
}
197204

198205
async #listenQueue(message: OutboxMessage): Promise<void> {
@@ -715,6 +722,7 @@ export class Federation<TContextData> {
715722
"The activity to send must have at least one actor property.",
716723
);
717724
}
725+
this.#startQueue();
718726
if (activity.id == null) {
719727
activity = activity.clone({
720728
id: new URL(`urn:uuid:${crypto.randomUUID()}`),
@@ -798,6 +806,7 @@ export class Federation<TContextData> {
798806
contextData,
799807
}: FederationFetchOptions<TContextData>,
800808
): Promise<Response> {
809+
this.#startQueue();
801810
onNotFound ??= notFound;
802811
onNotAcceptable ??= notAcceptable;
803812
const url = new URL(request.url);

0 commit comments

Comments
 (0)