-
Notifications
You must be signed in to change notification settings - Fork 6
add timeout to env for sampling messages #8
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
Changes from all commits
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 |
|---|---|---|
| @@ -0,0 +1,5 @@ | ||
| --- | ||
| "@iqai/mcp-discord": patch | ||
| --- | ||
|
|
||
| Adds timeout setting in env for sampling messages |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -32,6 +32,14 @@ const envSchema = z.object({ | |
| .optional() | ||
| .default(true) | ||
| .describe('Only respond to messages that mention the bot'), | ||
| SAMPLING_DEFAULT_TIMEOUT: z | ||
| .number() | ||
| .optional() | ||
| .describe('A timeout (in milliseconds) for this request'), | ||
| SAMPLING_REACTION_TIMEOUT: z | ||
| .number() | ||
| .optional() | ||
| .describe('A timeout for sending reactions to discord'), | ||
|
Comment on lines
+35
to
+42
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. For consistency with other configuration variables in this file (like |
||
| BLOCK_DMS: z | ||
| .stringbool() | ||
| .optional() | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -187,7 +187,10 @@ export class SamplingHandler { | |
| maxTokens: 10, | ||
| }, | ||
| }, | ||
| z.any() | ||
| z.any(), | ||
| { | ||
| timeout: env.SAMPLING_REACTION_TIMEOUT, | ||
| } | ||
| ); | ||
|
Comment on lines
+190
to
194
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. With the introduction of the Consider refactoring to use only the |
||
|
|
||
| const response = | ||
|
|
@@ -225,7 +228,8 @@ export class SamplingHandler { | |
| maxTokens: 200, | ||
| }, | ||
| }, | ||
| z.any() | ||
| z.any(), | ||
| { timeout: env.SAMPLING_DEFAULT_TIMEOUT } | ||
| ); | ||
| } | ||
|
|
||
|
|
||
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.
These new timeout configurations could be improved for robustness and clarity.
SAMPLING_DEFAULT_TIMEOUTandSAMPLING_REACTION_TIMEOUTare optional but lack default values. If not set, they will beundefined, which could lead to requests hanging if the underlying SDK has no default timeout. This is particularly risky forSAMPLING_DEFAULT_TIMEOUTas there's no other timeout mechanism for the main message sampling.SAMPLING_REACTION_TIMEOUTis inaccurate. It's a timeout for the sampling request, not for sending the reaction to Discord.I suggest adding default values and correcting the description to address these points.