@@ -284,7 +284,7 @@ class ServiceRunnerNode {
284284
285285 this . topics [ name ] = topic
286286
287- const routablePath = Path . join ( this . prefix , Path . normalize ( name ) )
287+ const routablePath = Path . normalize ( name )
288288
289289 let route = this . topicsRouter . add ( name , routablePath /*, this.topicHandler(topic)*/ )
290290
@@ -447,30 +447,53 @@ class ServiceRunnerNode {
447447 }
448448
449449 async getTopic ( path ) {
450- debug ( 'looking up route ' , path )
450+ debug ( 'looking up topic ' , path )
451451
452452 let p = new Promise ( async ( resolve , reject ) => {
453453
454- let route = await this . topicsRouter . route ( path , ( event ) => {
454+ //debug('\tcalling route', path)
455+ //debug('\t', Object.keys(this.topics))
455456
456- //debug(event)
457- //debug('topic route callback')
457+ try {
458458
459+ //debug('tryin', this.topicsRouter.route)
460+ let routed = false
461+
462+ let route = await this . topicsRouter . route ( path , ( event ) => {
463+
464+ //debug(event)
465+ //debug('topic route callback - ', path)
466+
467+
468+ if ( ! event . route ) {
469+ debug ( 'no such topic' , path )
470+ //reject('no such topic')
471+ routed = true
472+ resolve ( null )
473+ } else {
474+ debug ( 'found route' , event . route . name )
475+ }
459476
460- if ( ! event . route ) {
461- debug ( 'no such topic' , path )
462- //reject('no such topic')
463- resolve ( null )
464- } else {
465- debug ( 'found route' , event . route . name )
466- }
477+ routed = true
478+
479+ return resolve ( { route : event . route , topic : event . route . data , arguments : event . arguments } )
480+
481+ } )
467482
468- return resolve ( { route : event . route , topic : event . route . data , arguments : event . arguments } )
483+ debug ( '\trouting done' , routed )
469484
470- } )
485+ if ( ! routed ) {
486+ return reject ( null )
487+ }
488+
489+ } catch ( err ) {
471490
472- } )
491+ debug ( err )
473492
493+ return reject ( err )
494+ }
495+ } )
496+
474497 return await p
475498 }
476499
0 commit comments