File tree Expand file tree Collapse file tree 1 file changed +10
-0
lines changed
Expand file tree Collapse file tree 1 file changed +10
-0
lines changed Original file line number Diff line number Diff line change @@ -53,6 +53,16 @@ let cachedServer: Server | undefined;
5353async function getServer ( ) : Promise < Server > {
5454 if ( cachedServer === undefined ) {
5555 const bus = dbus . systemBus ( ) ;
56+ // dbus-next will queue messages and wait forever for a connection
57+ // so we have to hack in a timeout, otherwise we end up with a deadlock
58+ // on systems without D-Bus.
59+ await new Promise ( ( resolve , reject ) => setTimeout ( ( ) => {
60+ if ( ( bus as any ) . _connection . state === 'connected' ) {
61+ resolve ( ) ;
62+ } else {
63+ reject ( Error ( "Timeout while connecting to D-Bus" ) ) ;
64+ }
65+ } , 100 ) ) ;
5666 const proxy = await bus . getProxyObject ( 'org.freedesktop.Avahi' , '/' ) ;
5767 const server = proxy . getInterface < Server > ( 'org.freedesktop.Avahi.Server' ) ;
5868 const version = await server . GetAPIVersion ( ) ;
You can’t perform that action at this time.
0 commit comments