Shouqun / node-dbus

dbus module for node
MIT License
150 stars 70 forks source link

Error: No introspectable #222

Open benfrancis opened 4 years ago

benfrancis commented 4 years ago

Is there a way to stop node-dbus from trying to open a gtkDialog to display an error message?

I'm working on a kiosk application running on top of Ubuntu Core, which doesn't have a full desktop environment and trying to open this dialog just crashes the application. I'd like to be able to fail more gracefully and handle the error myself.

More specifically, if the application tries to call

systemBus.getInterface('org.freedesktop.NetworkManager', '/org/freedesktop/NetworkManager', 'org.freedesktop.NetworkManager', callback);

but the application doesn't have permission to access the network manager, then node-dbus fires an error saying "Error: No introspectable" and I see an error saying "GtkDialog mapped without a transient parent. This is discouraged." and my application fails to start. I'd to prevent that error from trying to open a GtkDialog and handle it myself.

benfrancis commented 4 years ago

I've discovered that this gtkDialog is actually being opened by Electron, due to an unhandled exception, so the dialog itself has nothing to do with node-dbus.

However, if there's a way to test whether a given interface is accessible before trying to call it (causing this unhandled exception), I'd be really grateful to find out as this is crashing my application.

ErwinSteffens commented 3 years ago

I have the same error. I have fixed the permissions. Any idea on what we are doing wrong here?

Here is the underlying error:

DBusError: Did not receive a reply. Possible causes include: the remote application did not send a reply, the message bus security policy blocked the reply, the reply timeout expired, or the network connection was broken.
    at new DBusError (/app/node_modules/dbus/lib/error.js:9:9)
    at createError (/app/node_modules/dbus/lib/bus.js:243:9) {
  dbusName: 'org.freedesktop.DBus.Error.NoReply'
}

Here are the message and response:

method call time=1609923796.324077 sender=:1.34 -> destination=org.freedesktop.timedate1 serial=3 path=/org/freedesktop/timedate1; interface=org.freedesktop.DBus.Introspectable; member=Introspect

method return time=1609923796.480598 sender=:1.36 -> destination=:1.34 serial=3 reply_serial=3
   string "<!DOCTYPE node PUBLIC "-//freedesktop//DTD D-BUS Object Introspection 1.0//EN"
"http://www.freedesktop.org/standards/dbus/1.0/introspect.dtd">
<node>
 <interface name="org.freedesktop.DBus.Peer">
  <method name="Ping"/>
  <method name="GetMachineId">
   <arg type="s" name="machine_uuid" direction="out"/>
  </method>
 </interface>
 <interface name="org.freedesktop.DBus.Introspectable">
  <method name="Introspect">
   <arg name="data" type="s" direction="out"/>
  </method>
 </interface>
 <interface name="org.freedesktop.DBus.Properties">
  <method name="Get">
   <arg name="interface" direction="in" type="s"/>
   <arg name="property" direction="in" type="s"/>
   <arg name="value" direction="out" type="v"/>
  </method>
  <method name="GetAll">
   <arg name="interface" direction="in" type="s"/>
   <arg name="properties" direction="out" type="a{sv}"/>
  </method>
  <method name="Set">
   <arg name="interface" direction="in" type="s"/>
   <arg name="property" direction="in" type="s"/>
   <arg name="value" direction="in" type="v"/>
  </method>
  <signal name="PropertiesChanged">
   <arg type="s" name="interface"/>
   <arg type="a{sv}" name="changed_properties"/>
   <arg type="as" name="invalidated_properties"/>
  </signal>
 </interface>
 <interface name="org.freedesktop.timedate1">
  <property name="Timezone" type="s" access="read">
  </property>
  <property name="LocalRTC" type="b" access="read">
  </property>
  <property name="CanNTP" type="b" access="read">
   <annotation name="org.freedesktop.DBus.Property.EmitsChangedSignal" value="false"/>
  </property>
  <property name="NTP" type="b" access="read">
  </property>
  <property name="NTPSynchronized" type="b" access="read">
   <annotation name="org.freedesktop.DBus.Property.EmitsChangedSignal" value="false"/>
  </property>
  <property name="TimeUSec" type="t" access="read">
   <annotation name="org.freedesktop.DBus.Property.EmitsChangedSignal" value="false"/>
  </property>
  <property name="RTCTimeUSec" type="t" access="read">
   <annotation name="org.freedesktop.DBus.Property.EmitsChangedSignal" value="false"/>
  </property>
  <method name="SetTime">
   <arg type="x" direction="in"/>
   <arg type="b" direction="in"/>
   <arg type="b" direction="in"/>
  </method>
  <method name="SetTimezone">
   <arg type="s" direction="in"/>
   <arg type="b" direction="in"/>
  </method>
  <method name="SetLocalRTC">
   <arg type="b" direction="in"/>
   <arg type="b" direction="in"/>
   <arg type="b" direction="in"/>
  </method>
  <method name="SetNTP">
   <arg type="b" direction="in"/>
   <arg type="b" direction="in"/>
  </method>
  <method name="ListTimezones">
   <arg type="as" direction="out"/>
  </method>
 </interface>
</node>
"
ErwinSteffens commented 3 years ago

Seems my issue is related to https://github.com/Shouqun/node-dbus/issues/183