-
Notifications
You must be signed in to change notification settings - Fork 623
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
Ignore error of writing responses to aborted requests #546
Conversation
This swallows only aborted connections? Or it may swallow also unexpected errors? Just wondering. |
@zekth |
I skipped the test case on windows because it doesn't implement |
http/util.ts
Outdated
@@ -0,0 +1,9 @@ | |||
// Sleeps the given milliseconds and resolves. | |||
export function sleep(ms: number): Promise<void> { |
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.
Nice addition. But we may also add this to _std? i often use it personnaly.
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.
I agree. This util is very useful. I moved the function to util/async.ts
. (I also changed the name to delay
because it sounds more general and node.js has delay module with almost the same purpose.)
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.
Looks good! Just one comment...
http/server_test.ts
Outdated
assert(serverIsRunning); | ||
} finally { | ||
// Stops the sever. | ||
p.kill(2); // SIGINT |
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.
You can use Deno.Signal.SIGINT
here
@@ -0,0 +1,9 @@ | |||
import { serve } from "../server.ts"; |
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.
Can you add a comment describing the purpose of this
// This is an example of a server that responds with an empty body
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.
LGTM
This PR fixes the case described in #442. The test case reproduces the case given by @MarkTiedemann in the comment ( #442 (comment) ).
This change simply ignore the error when the writing failed.
I believe the corresponding part of go's std library is here.
This doesn't handle the error returned by
fmt.Fprintf
. So this patch follows the above.closes #442