-
-
Notifications
You must be signed in to change notification settings - Fork 34
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Utilize AbortController (Request.signal) for APIs that make outgoing … #187
Changes from all commits
ef7eacd
95886fd
2d5c691
0798192
be01357
da59f06
b9b6499
782b1e5
506f2d3
d10cfa8
b348fa4
c9f1939
8fef4b8
edb4060
80dc403
5566789
035aa15
5589fa2
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -85,6 +85,9 @@ To be released. | |
- Let the `fedify lookup` command take multiple arguments. | ||
[[#173], [#186] by PGD] | ||
|
||
- Added options related to `AbortController`. | ||
[[#51] [#187] by PDJ] | ||
|
||
Comment on lines
+88
to
+90
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🛠️ Refactor suggestion Enhance the changelog entry for AbortController changes. The current entry is too brief. Consider expanding it to match the detail level of other entries by:
Apply this diff to enhance the changelog entry: - - Added options related to `AbortController`.
- [[#51] [#187] by PDJ]
+ - Added support for request cancellation using `AbortController`.
+ [[#51], [#187] by PDJ]
+
+ - Added optional `signal` parameter to the following interfaces:
+ - `GetDocumentLoaderOptions`
+ - `GetActorHandleOptions`
+ - `LookupObjectOptions`
+ - `LookupWebFingerOptions`
+
+ - The `signal` parameter enables control over the maximum duration
+ of outgoing API requests, preventing them from hanging indefinitely.
🧰 Tools🪛 Markdownlint (0.35.0)88-88: Expected: 0; Actual: 1 (MD007, ul-indent) |
||
|
||
[SvelteKit]: https://kit.svelte.dev/ | ||
[#162]: https://github.com/dahlia/fedify/issues/162 | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -130,6 +130,11 @@ spans: | |
| `object_integrity_proofs.verify` | Internal | Verifies the object integrity proof. | | ||
| `webfinger.handle` | Server | Handles the WebFinger request. | | ||
| `webfinger.lookup` | Client | Looks up the WebFinger resource. | | ||
| Operation | Span type | Description | | ||
|----------------------|-----------|-----------------------------------| | ||
| `Federation.fetch()` | Server | Serves the incoming HTTP request. | | ||
| `lookupWebFinger()` | Client | Looks up the WebFinger resource. | | ||
| `handleWebFinger()` | Server | Handles the WebFinger request. | | ||
|
||
More operations will be instrumented in the future releases. | ||
|
||
|
@@ -172,4 +177,21 @@ for ActivityPub: | |
| `webfinger.resource.scheme` | string | The scheme of the queried resource URI. | `"acct"` | | ||
|
||
[attributes]: https://opentelemetry.io/docs/specs/otel/common/#attribute | ||
| Attribute | Type | Description | Example | | ||
|----------------------------------|----------|---------------------------------------------------------------------------------|----------------------------------------------------| | ||
| `activitypub.activity.id` | string | The URI of the activity object. | `"https://example.com/activity/1"` | | ||
| `activitypub.activity.type` | string[] | The qualified URI(s) of the activity type(s). | `["https://www.w3.org/ns/activitystreams#Create"]` | | ||
| `activitypub.activity.to` | string[] | The URI(s) of the recipient collections/actors of the activity. | `["https://example.com/1/followers/2"]` | | ||
| `activitypub.activity.cc` | string[] | The URI(s) of the carbon-copied recipient collections/actors of the activity. | `["https://www.w3.org/ns/activitystreams#Public"]` | | ||
| `activitypub.activity.retries` | int | The ordinal number of activity resending attempt (if and only if it's retried). | `3` | | ||
| `activitypub.actor.id` | string | The URI of the actor object. | `"https://example.com/actor/1"` | | ||
| `activitypub.actor.type` | string[] | The qualified URI(s) of the actor type(s). | `["https://www.w3.org/ns/activitystreams#Person"]` | | ||
| `activitypub.object.id` | string | The URI of the object or the object enclosed by the activity. | `"https://example.com/object/1"` | | ||
| `activitypub.object.type` | string[] | The qualified URI(s) of the object type(s). | `["https://www.w3.org/ns/activitystreams#Note"]` | | ||
| `activitypub.object.in_reply_to` | string[] | The URI(s) of the original object to which the object reply. | `["https://example.com/object/1"]` | | ||
| `activitypub.inboxes` | int | The number of inboxes the activity is sent to. | `12` | | ||
| `activitypub.shared_inbox` | boolean | Whether the activity is sent to the shared inbox. | `true` | | ||
| `webfinger.resource` | string | The queried resource URI. | `"acct:[email protected]"` | | ||
| `webfinger.resource.scheme` | string | The scheme of the queried resource URI. | `"acct"` | | ||
|
||
[OpenTelemetry Semantic Conventions]: https://opentelemetry.io/docs/specs/semconv/ |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -45,6 +45,12 @@ export interface LookupObjectOptions { | |
* @since 1.3.0 | ||
*/ | ||
tracerProvider?: TracerProvider; | ||
|
||
/** | ||
* An optional abort signal to cancel the request. | ||
* @since 1.3.0 | ||
*/ | ||
signal?: AbortSignal | null; | ||
} | ||
|
||
const handleRegexp = | ||
|
@@ -147,6 +153,7 @@ async function lookupObjectInternal( | |
const jrd = await lookupWebFinger(identifier, { | ||
userAgent: options.userAgent, | ||
tracerProvider: options.tracerProvider, | ||
signal: options.signal, | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Propagate abort signal to documentLoader calls. While the signal is correctly passed to Consider updating the documentLoader calls: if (identifier.protocol === "http:" || identifier.protocol === "https:") {
try {
- const remoteDoc = await documentLoader(identifier.href);
+ const remoteDoc = await documentLoader(identifier.href, { signal: options.signal });
document = remoteDoc.document;
} catch (error) {
logger.debug("Failed to fetch remote document:\n{error}", { error });
}
} And: try {
- const remoteDoc = await documentLoader(l.href);
+ const remoteDoc = await documentLoader(l.href, { signal: options.signal });
document = remoteDoc.document;
break;
} catch (error) {
|
||
}); | ||
if (jrd?.links == null) return null; | ||
for (const l of jrd.links) { | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🛠️ Refactor suggestion
Fix list indentation.
The indentation of the bullet point doesn't match the style of other entries in the changelog.
Apply this diff to fix the indentation:
📝 Committable suggestion
🧰 Tools
🪛 Markdownlint (0.35.0)
75-75: Expected: 0; Actual: 1
Unordered list indentation
(MD007, ul-indent)