{"action":"created","comment":{"url":"https://api.github.com/repos/monzo/typhon/pulls/comments/180086144","pull_request_review_id":110444067,"id":180086144,"diff_hunk":"@@ -22,6 +22,11 @@ var (\n \t\tterrors.ErrPreconditionFailed: http.StatusPreconditionFailed,\n \t\tterrors.ErrTimeout:            http.StatusGatewayTimeout,\n \t\tterrors.ErrUnauthorized:       http.StatusUnauthorized,\n+\n+\t\t// If the client disconnects it won't receive this response status code\n+\t\t// However, this allows intermediate proxies to distinguish this behaviour\n+\t\t// giving similar behaviour to nginx\n+\t\tterrors.ErrContextCanceled: 499,","path":"terrors.go","position":8,"original_position":8,"commit_id":"08b1c8759c5f5d8df662b3520ce093347ca271f7","original_commit_id":"08b1c8759c5f5d8df662b3520ce093347ca271f7","user":{"login":"mattheath","id":181548,"avatar_url":"https://avatars3.githubusercontent.com/u/181548?v=4","gravatar_id":"","url":"https://api.github.com/users/mattheath","html_url":"https://github.com/mattheath","followers_url":"https://api.github.com/users/mattheath/followers","following_url":"https://api.github.com/users/mattheath/following{/other_user}","gists_url":"https://api.github.com/users/mattheath/gists{/gist_id}","starred_url":"https://api.github.com/users/mattheath/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/mattheath/subscriptions","organizations_url":"https://api.github.com/users/mattheath/orgs","repos_url":"https://api.github.com/users/mattheath/repos","events_url":"https://api.github.com/users/mattheath/events{/privacy}","received_events_url":"https://api.github.com/users/mattheath/received_events","type":"User","site_admin":false},"body":"Ok, I'll see if we can pin down when it's a specific client disconnection causing the context cancellation.","created_at":"2018-04-09T13:02:15Z","updated_at":"2018-04-09T13:02:15Z","html_url":"https://github.com/monzo/typhon/pull/86#discussion_r180086144","pull_request_url":"https://api.github.com/repos/monzo/typhon/pulls/86","author_association":"OWNER","_links":{"self":{"href":"https://api.github.com/repos/monzo/typhon/pulls/comments/180086144"},"html":{"href":"https://github.com/monzo/typhon/pull/86#discussion_r180086144"},"pull_request":{"href":"https://api.github.com/repos/monzo/typhon/pulls/86"}},"in_reply_to_id":180062278},"pull_request":{"url":"https://api.github.com/repos/monzo/typhon/pulls/86","id":180083406,"html_url":"https://github.com/monzo/typhon/pull/86","diff_url":"https://github.com/monzo/typhon/pull/86.diff","patch_url":"https://github.com/monzo/typhon/pull/86.patch","issue_url":"https://api.github.com/repos/monzo/typhon/issues/86","number":86,"state":"open","locked":false,"title":"Add 499 status code for request cancelation","user":{"login":"mattheath","id":181548,"avatar_url":"https://avatars3.githubusercontent.com/u/181548?v=4","gravatar_id":"","url":"https://api.github.com/users/mattheath","html_url":"https://github.com/mattheath","followers_url":"https://api.github.com/users/mattheath/followers","following_url":"https://api.github.com/users/mattheath/following{/other_user}","gists_url":"https://api.github.com/users/mattheath/gists{/gist_id}","starred_url":"https://api.github.com/users/mattheath/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/mattheath/subscriptions","organizations_url":"https://api.github.com/users/mattheath/orgs","repos_url":"https://api.github.com/users/mattheath/repos","events_url":"https://api.github.com/users/mattheath/events{/privacy}","received_events_url":"https://api.github.com/users/mattheath/received_events","type":"User","site_admin":false},"body":"Similar to monzo/terrors#8 I'd like to be able to identify context/request cancelations, and return a specific status code for these. In the case of a client disconnection triggering the request cancelation the status code will not actually be returned to the client, but is still useful for intermediate proxies / services. \r\n\r\nI've copied nginx here, using the non-standard `499` status code to represent this.\r\n\r\nSomething which is a bit more interesting is this effectively identifies a context being canceled somewhere down the request chain bubbling up to the http server. There are arguably two subtly different cases which we should consider:\r\n\r\n - The parent request which this http server is processing has been canceled (parent context canceled). I think this should return a 499 or similar, allowing proxies to log or handle this.\r\n - A child request has been canceled due to a deadline being exceeded, but the parent context which this http server is processing is _not_ \"Done\". In this case the client is still connected, and returning a 499 status code to the client is not acceptable - this should perhaps default back to an internal service error of some form.\r\n\r\nI _think_ we can distinguish between these two cases in the `ErrorFilter` by checking the status of the request context, but I'd love some thoughts on this before I tackle it. In the simple case, adding this error code will get us part of the way there, and fixes my immediate problem 😄 ","created_at":"2018-04-07T01:40:33Z","updated_at":"2018-04-09T13:02:15Z","closed_at":null,"merged_at":null,"merge_commit_sha":"14ade0604b2a2a329637e0527b0b42cfc17ee863","assignee":null,"assignees":[],"requested_reviewers":[],"requested_teams":[],"labels":[],"milestone":null,"commits_url":"https://api.github.com/repos/monzo/typhon/pulls/86/commits","review_comments_url":"https://api.github.com/repos/monzo/typhon/pulls/86/comments","review_comment_url":"https://api.github.com/repos/monzo/typhon/pulls/comments{/number}","comments_url":"https://api.github.com/repos/monzo/typhon/issues/86/comments","statuses_url":"https://api.github.com/repos/monzo/typhon/statuses/08b1c8759c5f5d8df662b3520ce093347ca271f7","head":{"label":"monzo:request_cancelation_status","ref":"request_cancelation_status","sha":"08b1c8759c5f5d8df662b3520ce093347ca271f7","user":{"login":"monzo","id":11029372,"avatar_url":"https://avatars3.githubusercontent.com/u/11029372?v=4","gravatar_id":"","url":"https://api.github.com/users/monzo","html_url":"https://github.com/monzo","followers_url":"https://api.github.com/users/monzo/followers","following_url":"https://api.github.com/users/monzo/following{/other_user}","gists_url":"https://api.github.com/users/monzo/gists{/gist_id}","starred_url":"https://api.github.com/users/monzo/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/monzo/subscriptions","organizations_url":"https://api.github.com/users/monzo/orgs","repos_url":"https://api.github.com/users/monzo/repos","events_url":"https://api.github.com/users/monzo/events{/privacy}","received_events_url":"https://api.github.com/users/monzo/received_events","type":"Organization","site_admin":false},"repo":{"id":30697332,"name":"typhon","full_name":"monzo/typhon","owner":{"login":"monzo","id":11029372,"avatar_url":"https://avatars3.githubusercontent.com/u/11029372?v=4","gravatar_id":"","url":"https://api.github.com/users/monzo","html_url":"https://github.com/monzo","followers_url":"https://api.github.com/users/monzo/followers","following_url":"https://api.github.com/users/monzo/following{/other_user}","gists_url":"https://api.github.com/users/monzo/gists{/gist_id}","starred_url":"https://api.github.com/users/monzo/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/monzo/subscriptions","organizations_url":"https://api.github.com/users/monzo/orgs","repos_url":"https://api.github.com/users/monzo/repos","events_url":"https://api.github.com/users/monzo/events{/privacy}","received_events_url":"https://api.github.com/users/monzo/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/monzo/typhon","description":"A thin wrapper around Go's net/http that we use at Monzo to build RPC servers and clients in our microservices platform.","fork":false,"url":"https://api.github.com/repos/monzo/typhon","forks_url":"https://api.github.com/repos/monzo/typhon/forks","keys_url":"https://api.github.com/repos/monzo/typhon/keys{/key_id}","collaborators_url":"https://api.github.com/repos/monzo/typhon/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/monzo/typhon/teams","hooks_url":"https://api.github.com/repos/monzo/typhon/hooks","issue_events_url":"https://api.github.com/repos/monzo/typhon/issues/events{/number}","events_url":"https://api.github.com/repos/monzo/typhon/events","assignees_url":"https://api.github.com/repos/monzo/typhon/assignees{/user}","branches_url":"https://api.github.com/repos/monzo/typhon/branches{/branch}","tags_url":"https://api.github.com/repos/monzo/typhon/tags","blobs_url":"https://api.github.com/repos/monzo/typhon/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/monzo/typhon/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/monzo/typhon/git/refs{/sha}","trees_url":"https://api.github.com/repos/monzo/typhon/git/trees{/sha}","statuses_url":"https://api.github.com/repos/monzo/typhon/statuses/{sha}","languages_url":"https://api.github.com/repos/monzo/typhon/languages","stargazers_url":"https://api.github.com/repos/monzo/typhon/stargazers","contributors_url":"https://api.github.com/repos/monzo/typhon/contributors","subscribers_url":"https://api.github.com/repos/monzo/typhon/subscribers","subscription_url":"https://api.github.com/repos/monzo/typhon/subscription","commits_url":"https://api.github.com/repos/monzo/typhon/commits{/sha}","git_commits_url":"https://api.github.com/repos/monzo/typhon/git/commits{/sha}","comments_url":"https://api.github.com/repos/monzo/typhon/comments{/number}","issue_comment_url":"https://api.github.com/repos/monzo/typhon/issues/comments{/number}","contents_url":"https://api.github.com/repos/monzo/typhon/contents/{+path}","compare_url":"https://api.github.com/repos/monzo/typhon/compare/{base}...{head}","merges_url":"https://api.github.com/repos/monzo/typhon/merges","archive_url":"https://api.github.com/repos/monzo/typhon/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/monzo/typhon/downloads","issues_url":"https://api.github.com/repos/monzo/typhon/issues{/number}","pulls_url":"https://api.github.com/repos/monzo/typhon/pulls{/number}","milestones_url":"https://api.github.com/repos/monzo/typhon/milestones{/number}","notifications_url":"https://api.github.com/repos/monzo/typhon/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/monzo/typhon/labels{/name}","releases_url":"https://api.github.com/repos/monzo/typhon/releases{/id}","deployments_url":"https://api.github.com/repos/monzo/typhon/deployments","created_at":"2015-02-12T10:21:42Z","updated_at":"2018-04-09T00:10:40Z","pushed_at":"2018-04-07T01:40:34Z","git_url":"git://github.com/monzo/typhon.git","ssh_url":"git@github.com:monzo/typhon.git","clone_url":"https://github.com/monzo/typhon.git","svn_url":"https://github.com/monzo/typhon","homepage":"","size":397,"stargazers_count":255,"watchers_count":255,"language":"Go","has_issues":true,"has_projects":false,"has_downloads":true,"has_wiki":false,"has_pages":false,"forks_count":17,"mirror_url":null,"archived":false,"open_issues_count":1,"license":{"key":"mit","name":"MIT License","spdx_id":"MIT","url":"https://api.github.com/licenses/mit"},"forks":17,"open_issues":1,"watchers":255,"default_branch":"master"}},"base":{"label":"monzo:master","ref":"master","sha":"5c63e484c906f6a870d60e188b13c9beada0645f","user":{"login":"monzo","id":11029372,"avatar_url":"https://avatars3.githubusercontent.com/u/11029372?v=4","gravatar_id":"","url":"https://api.github.com/users/monzo","html_url":"https://github.com/monzo","followers_url":"https://api.github.com/users/monzo/followers","following_url":"https://api.github.com/users/monzo/following{/other_user}","gists_url":"https://api.github.com/users/monzo/gists{/gist_id}","starred_url":"https://api.github.com/users/monzo/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/monzo/subscriptions","organizations_url":"https://api.github.com/users/monzo/orgs","repos_url":"https://api.github.com/users/monzo/repos","events_url":"https://api.github.com/users/monzo/events{/privacy}","received_events_url":"https://api.github.com/users/monzo/received_events","type":"Organization","site_admin":false},"repo":{"id":30697332,"name":"typhon","full_name":"monzo/typhon","owner":{"login":"monzo","id":11029372,"avatar_url":"https://avatars3.githubusercontent.com/u/11029372?v=4","gravatar_id":"","url":"https://api.github.com/users/monzo","html_url":"https://github.com/monzo","followers_url":"https://api.github.com/users/monzo/followers","following_url":"https://api.github.com/users/monzo/following{/other_user}","gists_url":"https://api.github.com/users/monzo/gists{/gist_id}","starred_url":"https://api.github.com/users/monzo/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/monzo/subscriptions","organizations_url":"https://api.github.com/users/monzo/orgs","repos_url":"https://api.github.com/users/monzo/repos","events_url":"https://api.github.com/users/monzo/events{/privacy}","received_events_url":"https://api.github.com/users/monzo/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/monzo/typhon","description":"A thin wrapper around Go's net/http that we use at Monzo to build RPC servers and clients in our microservices platform.","fork":false,"url":"https://api.github.com/repos/monzo/typhon","forks_url":"https://api.github.com/repos/monzo/typhon/forks","keys_url":"https://api.github.com/repos/monzo/typhon/keys{/key_id}","collaborators_url":"https://api.github.com/repos/monzo/typhon/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/monzo/typhon/teams","hooks_url":"https://api.github.com/repos/monzo/typhon/hooks","issue_events_url":"https://api.github.com/repos/monzo/typhon/issues/events{/number}","events_url":"https://api.github.com/repos/monzo/typhon/events","assignees_url":"https://api.github.com/repos/monzo/typhon/assignees{/user}","branches_url":"https://api.github.com/repos/monzo/typhon/branches{/branch}","tags_url":"https://api.github.com/repos/monzo/typhon/tags","blobs_url":"https://api.github.com/repos/monzo/typhon/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/monzo/typhon/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/monzo/typhon/git/refs{/sha}","trees_url":"https://api.github.com/repos/monzo/typhon/git/trees{/sha}","statuses_url":"https://api.github.com/repos/monzo/typhon/statuses/{sha}","languages_url":"https://api.github.com/repos/monzo/typhon/languages","stargazers_url":"https://api.github.com/repos/monzo/typhon/stargazers","contributors_url":"https://api.github.com/repos/monzo/typhon/contributors","subscribers_url":"https://api.github.com/repos/monzo/typhon/subscribers","subscription_url":"https://api.github.com/repos/monzo/typhon/subscription","commits_url":"https://api.github.com/repos/monzo/typhon/commits{/sha}","git_commits_url":"https://api.github.com/repos/monzo/typhon/git/commits{/sha}","comments_url":"https://api.github.com/repos/monzo/typhon/comments{/number}","issue_comment_url":"https://api.github.com/repos/monzo/typhon/issues/comments{/number}","contents_url":"https://api.github.com/repos/monzo/typhon/contents/{+path}","compare_url":"https://api.github.com/repos/monzo/typhon/compare/{base}...{head}","merges_url":"https://api.github.com/repos/monzo/typhon/merges","archive_url":"https://api.github.com/repos/monzo/typhon/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/monzo/typhon/downloads","issues_url":"https://api.github.com/repos/monzo/typhon/issues{/number}","pulls_url":"https://api.github.com/repos/monzo/typhon/pulls{/number}","milestones_url":"https://api.github.com/repos/monzo/typhon/milestones{/number}","notifications_url":"https://api.github.com/repos/monzo/typhon/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/monzo/typhon/labels{/name}","releases_url":"https://api.github.com/repos/monzo/typhon/releases{/id}","deployments_url":"https://api.github.com/repos/monzo/typhon/deployments","created_at":"2015-02-12T10:21:42Z","updated_at":"2018-04-09T00:10:40Z","pushed_at":"2018-04-07T01:40:34Z","git_url":"git://github.com/monzo/typhon.git","ssh_url":"git@github.com:monzo/typhon.git","clone_url":"https://github.com/monzo/typhon.git","svn_url":"https://github.com/monzo/typhon","homepage":"","size":397,"stargazers_count":255,"watchers_count":255,"language":"Go","has_issues":true,"has_projects":false,"has_downloads":true,"has_wiki":false,"has_pages":false,"forks_count":17,"mirror_url":null,"archived":false,"open_issues_count":1,"license":{"key":"mit","name":"MIT License","spdx_id":"MIT","url":"https://api.github.com/licenses/mit"},"forks":17,"open_issues":1,"watchers":255,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/monzo/typhon/pulls/86"},"html":{"href":"https://github.com/monzo/typhon/pull/86"},"issue":{"href":"https://api.github.com/repos/monzo/typhon/issues/86"},"comments":{"href":"https://api.github.com/repos/monzo/typhon/issues/86/comments"},"review_comments":{"href":"https://api.github.com/repos/monzo/typhon/pulls/86/comments"},"review_comment":{"href":"https://api.github.com/repos/monzo/typhon/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/monzo/typhon/pulls/86/commits"},"statuses":{"href":"https://api.github.com/repos/monzo/typhon/statuses/08b1c8759c5f5d8df662b3520ce093347ca271f7"}},"author_association":"OWNER"}}
{"actor":{"display_login":"mattheath"}}