From 70e414b27988988b3059709c1d2a98b62dc4b03c Mon Sep 17 00:00:00 2001 From: Cheng Zhao Date: Sat, 1 Jun 2013 14:09:53 +0800 Subject: [PATCH] Check the existence of socketPath. See the comments for the reason. --- src/atom-application.coffee | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/src/atom-application.coffee b/src/atom-application.coffee index d0c67ca76..da4dd5b67 100644 --- a/src/atom-application.coffee +++ b/src/atom-application.coffee @@ -13,12 +13,22 @@ socketPath = '/tmp/atom.sock' module.exports = class AtomApplication @open: (options) -> + createAtomApplication = -> new AtomApplication(options) + + # FIXME: Sometimes when socketPath doesn't exist, net.connect would strangely + # take a few seconds to trigger 'error' event, it could be a bug of node + # or atom-shell, before it's fixed we check the existence of socketPath to + # speedup startup. + if not fs.existsSync socketPath + createAtomApplication() + return + client = net.connect {path: socketPath}, -> client.write JSON.stringify(options), -> client.end() app.terminate() - client.on 'error', -> new AtomApplication(options) + client.on 'error', createAtomApplication windows: null configWindow: null