-
Notifications
You must be signed in to change notification settings - Fork 58
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
feat: Add Koa Server Request Timeout #2504
Changes from 1 commit
9eda6bf
432089b
ee2433f
ed825b6
7fb85ec
ddbd07c
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 |
---|---|---|
|
@@ -21,7 +21,11 @@ | |
import app from './server'; | ||
|
||
async function main() { | ||
await app.listen({ port: process.env.SERVER_PORT || 7546 }); | ||
const server = await app.listen({ port: process.env.SERVER_PORT || 7546 }); | ||
|
||
// set request timeout to ensure sockets are closed after specified time | ||
const requestTimeoutMs = parseInt(process.env.SERVER_REQUEST_TIMEOUT_MS!) || 30000; | ||
server.setTimeout(requestTimeoutMs); | ||
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. Add a test to confirm relay sends timeout in this case 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. Done. 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. The setTimeout method allows to send a callback function that will be executed in case a timeout is executed: I think we should use it to capture metrics of timeouts. however, we don't have the registry yet in here... so I was thinking if we can change the approach and do something like this?? I haven't tested this yet, but basically uses: and move it to file and do it something like this:
|
||
} | ||
|
||
main(); |
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.
Set timeout appropriately.
Maybe 60 secs or more.
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.
Done.