payload: {"action":"created","issue":{"url":"https://api.github.com/repos/sindresorhus/got/issues/887","repository_url":"https://api.github.com/repos/sindresorhus/got","labels_url":"https://api.github.com/repos/sindresorhus/got/issues/887/labels{/name}","comments_url":"https://api.github.com/repos/sindresorhus/got/issues/887/comments","events_url":"https://api.github.com/repos/sindresorhus/got/issues/887/events","html_url":"https://github.com/sindresorhus/got/issues/887","id":496512129,"node_id":"MDU6SXNzdWU0OTY1MTIxMjk=","number":887,"title":"How do I catch ECONNREFUSED / ENOTFOUND error in got.post when streaming data?","user":{"login":"builtbylane","id":149081,"node_id":"MDQ6VXNlcjE0OTA4MQ==","avatar_url":"https://avatars3.githubusercontent.com/u/149081?v=4","gravatar_id":"","url":"https://api.github.com/users/builtbylane","html_url":"https://github.com/builtbylane","followers_url":"https://api.github.com/users/builtbylane/followers","following_url":"https://api.github.com/users/builtbylane/following{/other_user}","gists_url":"https://api.github.com/users/builtbylane/gists{/gist_id}","starred_url":"https://api.github.com/users/builtbylane/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/builtbylane/subscriptions","organizations_url":"https://api.github.com/users/builtbylane/orgs","repos_url":"https://api.github.com/users/builtbylane/repos","events_url":"https://api.github.com/users/builtbylane/events{/privacy}","received_events_url":"https://api.github.com/users/builtbylane/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":1,"created_at":"2019-09-20T19:29:26Z","updated_at":"2019-09-20T20:13:13Z","closed_at":null,"author_association":"NONE","body":"How do I prevent my app from crashing when posting a stream to an offline destination? In both examples below I get: \r\n```\r\ninternal/streams/legacy.js:59\r\n      throw er; // Unhandled stream error in pipe.\r\n      ^\r\n\r\nError: connect ECONNREFUSED 127.0.0.1:2024\r\n    at TCPConnectWrap.afterConnect\r\n```\r\n\r\n(I'm on node v12.1.0)\r\n\r\n```javascript\r\nimport FormData from 'form-data';\r\nimport got from 'got';\r\nimport fs from 'fs';\r\n\r\n(async () => {\r\n  try {\r\n    const form = new FormData();\r\n    form.append('upload', fs.createReadStream('filepath.jpg'));\r\n    await got.post('http://offlinesite123.com', {\r\n      body: form,\r\n    });\r\n  } catch (err) {\r\n    console.error('does not catch', err);\r\n  }\r\n})();\r\n```\r\n\r\nthis also crashes my app\r\n\r\n```javascript\r\ntry {\r\n  const form = new FormData();\r\n  form.append('upload', fs.createReadStream('filepath.jpg'));\r\n  got.stream\r\n    .post('http://offlinesite123.com', {\r\n      body: form,\r\n    })\r\n    .on('error', err => console.error('this error gets reported but app still crashes'));\r\n} catch (err) {\r\n  console.error('does not catch', err);\r\n}\r\n```\r\n\r\n#### Checklist\r\n\r\n- [x] I have read the documentation.\r\n"},"comment":{"url":"https://api.github.com/repos/sindresorhus/got/issues/comments/533693911","html_url":"https://github.com/sindresorhus/got/issues/887#issuecomment-533693911","issue_url":"https://api.github.com/repos/sindresorhus/got/issues/887","id":533693911,"node_id":"MDEyOklzc3VlQ29tbWVudDUzMzY5MzkxMQ==","user":{"login":"szmarczak","id":36894700,"node_id":"MDQ6VXNlcjM2ODk0NzAw","avatar_url":"https://avatars0.githubusercontent.com/u/36894700?v=4","gravatar_id":"","url":"https://api.github.com/users/szmarczak","html_url":"https://github.com/szmarczak","followers_url":"https://api.github.com/users/szmarczak/followers","following_url":"https://api.github.com/users/szmarczak/following{/other_user}","gists_url":"https://api.github.com/users/szmarczak/gists{/gist_id}","starred_url":"https://api.github.com/users/szmarczak/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/szmarczak/subscriptions","organizations_url":"https://api.github.com/users/szmarczak/orgs","repos_url":"https://api.github.com/users/szmarczak/repos","events_url":"https://api.github.com/users/szmarczak/events{/privacy}","received_events_url":"https://api.github.com/users/szmarczak/received_events","type":"User","site_admin":false},"created_at":"2019-09-20T20:13:13Z","updated_at":"2019-09-20T20:13:13Z","author_association":"COLLABORATOR","body":"I think we need to use `Stream.pipeline` here: https://github.com/sindresorhus/got/blob/master/source/request-as-event-emitter.ts#L229"}}
other: {"actor":{"display_login":"szmarczak"}}