{"action":"opened","issue":{"url":"https://api.github.com/repos/electron/electron/issues/6521","repository_url":"https://api.github.com/repos/electron/electron","labels_url":"https://api.github.com/repos/electron/electron/issues/6521/labels{/name}","comments_url":"https://api.github.com/repos/electron/electron/issues/6521/comments","events_url":"https://api.github.com/repos/electron/electron/issues/6521/events","html_url":"https://github.com/electron/electron/issues/6521","id":165978663,"number":6521,"title":"Allow the response for `sendSync` to be asynchronous.","user":{"login":"tarruda","id":842846,"avatar_url":"https://avatars.githubusercontent.com/u/842846?v=3","gravatar_id":"","url":"https://api.github.com/users/tarruda","html_url":"https://github.com/tarruda","followers_url":"https://api.github.com/users/tarruda/followers","following_url":"https://api.github.com/users/tarruda/following{/other_user}","gists_url":"https://api.github.com/users/tarruda/gists{/gist_id}","starred_url":"https://api.github.com/users/tarruda/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/tarruda/subscriptions","organizations_url":"https://api.github.com/users/tarruda/orgs","repos_url":"https://api.github.com/users/tarruda/repos","events_url":"https://api.github.com/users/tarruda/events{/privacy}","received_events_url":"https://api.github.com/users/tarruda/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":0,"created_at":"2016-07-17T14:19:31Z","updated_at":"2016-07-17T14:19:31Z","closed_at":null,"body":"I would like to use `sendSync` to make some computation in the main process and return the result, but this computation can only be done asynchronously in the main process(which is expected or there could be a deadlock).\r\n\r\nThe documentation example for `sendSync` shows something like this:\r\n\r\n```js\r\n// main process\r\nipcMain.on('synchronous-message', (event, arg) => {\r\n  console.log(arg);  // prints \"ping\"\r\n  event.returnValue = 'pong';\r\n});\r\n\r\n// renderer process\r\nconsole.log(ipcRenderer.sendSync('synchronous-message', 'ping')); // prints \"pong\"\r\n```\r\n\r\nThis snippet suggests that the handler for a synchronous message must return the result synchronously, but what I need is for the handler to be defined like this:\r\n\r\n```js\r\nipcMain.on('synchronous-message', (event, arg) => {\r\n  console.log(arg);  // prints \"ping\"\r\n  setImmediate(() => {\r\n    event.callback('pong');\r\n  });\r\n});\r\n```\r\n\r\nCan the API be changed to allow this use case?"}}
{"actor":{"display_login":"tarruda"}}