def provision_socket
      ensure_startup unless @pid

      wait_socket = nil
      checks = 0
      max_retries = 12

      while checks < max_retries
        begin
          checks += 1
          wait_socket = UNIXSocket.new(@port)
          break
        rescue Errno::ENOENT, Errno::ECONNREFUSED, Errno::ENOTDIR
          wait_socket = nil
          sleep 0.5
        end
      end

      if checks >= max_retries
        ensure_shutdown
        raise ExecJS::RuntimeError, "unable to connect to alaska.js server"
      end

      wait_socket
    end
def provision_socket
      ensure_startup unless @pid

      wait_socket = nil
      checks = 0
      max_retries = 12

      while checks < max_retries
        begin
          checks += 1
          wait_socket = UNIXSocket.new(@port)
          break
        rescue Errno::ENOENT, Errno::ECONNREFUSED, Errno::ENOTDIR
          wait_socket = nil
          sleep 0.5
        end
      end

      if checks >= max_retries
        ensure_shutdown
        raise ExecJS::RuntimeError, "unable to connect to alaska.js server"
      end

      wait_socket
    end
NOTE: this should be thread-safe