{"action":"closed","issue":{"url":"https://api.github.com/repos/electron/electron/issues/16232","repository_url":"https://api.github.com/repos/electron/electron","labels_url":"https://api.github.com/repos/electron/electron/issues/16232/labels{/name}","comments_url":"https://api.github.com/repos/electron/electron/issues/16232/comments","events_url":"https://api.github.com/repos/electron/electron/issues/16232/events","html_url":"https://github.com/electron/electron/issues/16232","id":395202742,"node_id":"MDU6SXNzdWUzOTUyMDI3NDI=","number":16232,"title":"`socket` timeout trigger after socket destroy","user":{"login":"githoniel","id":17848159,"node_id":"MDQ6VXNlcjE3ODQ4MTU5","avatar_url":"https://avatars3.githubusercontent.com/u/17848159?v=4","gravatar_id":"","url":"https://api.github.com/users/githoniel","html_url":"https://github.com/githoniel","followers_url":"https://api.github.com/users/githoniel/followers","following_url":"https://api.github.com/users/githoniel/following{/other_user}","gists_url":"https://api.github.com/users/githoniel/gists{/gist_id}","starred_url":"https://api.github.com/users/githoniel/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/githoniel/subscriptions","organizations_url":"https://api.github.com/users/githoniel/orgs","repos_url":"https://api.github.com/users/githoniel/repos","events_url":"https://api.github.com/users/githoniel/events{/privacy}","received_events_url":"https://api.github.com/users/githoniel/received_events","type":"User","site_admin":false},"labels":[],"state":"closed","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":3,"created_at":"2019-01-02T10:21:49Z","updated_at":"2019-01-04T16:31:12Z","closed_at":"2019-01-04T16:31:11Z","author_association":"NONE","body":"### Version Info\r\nelectron: 4.0.0\r\nOS: Windows 10   x64 10.0.17134.472\r\n\r\n### Expected Behavior \r\n```js\r\n      const response = await axios.get(path, {\r\n            params: sendData,\r\n            responseType: 'stream',\r\n            cancelToken,\r\n            transformRequest: [t => t]\r\n        })\r\n        const event = new EventEmitter()\r\n        // bug with electron 4.0 \r\n        response.data.client.setTimeout(10000, () => {\r\n             // this event will trigger after download success\r\n            // event destory socket manually does not help\r\n            event.emit('error', new ErrorWithCode(\r\n                ErrorType.DOWNLOAD_ERROR,\r\n                ErrorCode.DOWNLOAD_TIMEOUT\r\n            ))\r\n        })\r\n        response.data.on('end', () => {\r\n            // add destory()  does  not prevent timeout event trigger\r\n            response.data.client.destroy()\r\n            this._emmitDownLoadProgress(event, {              \r\n                downloadedPercent: 100\r\n            })\r\n        }).on('error', (e) => {\r\n            event.emit('error', new ErrorWithCode(\r\n                ErrorType.DOWNLOAD_ERROR,\r\n                ErrorCode.STREAM_ERROR,\r\n                e.message\r\n            ))\r\n        })\r\n        writeStream.on('finish', () => {\r\n                event.emit('end')\r\n            }\r\n        })\r\n        response.data.pipe(writeStream)\r\n        return event\r\n```\r\nIn NodeJS v10.15.0 / NodeJS v8 / NodeJS v6 / electron v1.8.x /  electron 2.X, \r\n the timeout function registered by `response.data.client.setTimeout` will not trigger after download success.\r\n\r\n### Actual Behavior\r\n\r\nin electron 4.0, it will trigger whatever it is download success or not， even after `destory`\r\n"}}
{"actor":{"display_login":"githoniel"}}