File tree 1 file changed +8
-10
lines changed
packages/orchestration/src/exos
1 file changed +8
-10
lines changed Original file line number Diff line number Diff line change @@ -126,7 +126,7 @@ export const preparePacketTools = (zone, vowTools) => {
126
126
const resolverToPattern = zone . detached ( ) . mapStore ( 'resolverToPattern' ) ;
127
127
return {
128
128
lca,
129
- reg : /** @type {Remote <TargetRegistration> | null } */ ( null ) ,
129
+ reg : /** @type {Vow <TargetRegistration> | null } */ ( null ) ,
130
130
resolverToPattern,
131
131
upcallQueue : /** @type {any[] | null } */ ( null ) ,
132
132
pending : 0 ,
@@ -331,17 +331,15 @@ export const preparePacketTools = (zone, vowTools) => {
331
331
} ,
332
332
subscribeToTransfers ( ) {
333
333
// Subscribe to the transfers for this account.
334
- const { lca, reg } = this . state ;
335
- if ( reg ) {
336
- return when ( reg ) ;
334
+ const { lca, reg : cachedReg } = this . state ;
335
+ if ( cachedReg ) {
336
+ return when ( cachedReg ) ;
337
337
}
338
+ // Atomically update the registration.
338
339
const { tap } = this . facets ;
339
- // XXX racy; fails if subscribeToTransfers is called while this promise is in flight
340
- // e.g. 'Target "agoric1fakeLCAAddress" already registered'
341
- return when ( E ( lca ) . monitorTransfers ( tap ) , r => {
342
- this . state . reg = r ;
343
- return r ;
344
- } ) ;
340
+ const reg = watch ( E ( lca ) . monitorTransfers ( tap ) ) ;
341
+ this . state . reg = reg ;
342
+ return when ( reg ) ;
345
343
} ,
346
344
unsubscribeFromTransfers ( ) {
347
345
const { reg, monitor } = this . state ;
You can’t perform that action at this time.
0 commit comments