@@ -22,6 +22,7 @@ const ServerOptionsSchema = Type.Object({
22
22
port : Type . Integer ( ) ,
23
23
auth_token : Type . String ( ) ,
24
24
external_base_url : Type . String ( ) ,
25
+ wait_for_chainhook_node : Type . Boolean ( { default : true } ) ,
25
26
} ) ;
26
27
/** Local event server connection and authentication options */
27
28
export type ServerOptions = Static < typeof ServerOptionsSchema > ;
@@ -92,6 +93,10 @@ export async function buildServer(
92
93
}
93
94
94
95
async function registerPredicates ( this : FastifyInstance ) {
96
+ if ( predicates . length === 0 ) {
97
+ logger . info ( `ChainhookEventObserver does not have predicates to register` ) ;
98
+ return ;
99
+ }
95
100
logger . info (
96
101
predicates ,
97
102
`ChainhookEventObserver registering predicates at ${ chainhookOpts . base_url } `
@@ -123,6 +128,10 @@ export async function buildServer(
123
128
}
124
129
125
130
async function removePredicates ( this : FastifyInstance ) {
131
+ if ( predicates . length === 0 ) {
132
+ logger . info ( `ChainhookEventObserver does not have predicates to close` ) ;
133
+ return ;
134
+ }
126
135
logger . info ( `ChainhookEventObserver closing predicates at ${ chainhookOpts . base_url } ` ) ;
127
136
const removals = predicates . map (
128
137
predicate =>
@@ -196,7 +205,9 @@ export async function buildServer(
196
205
bodyLimit : 41943040 , // 40 MB
197
206
} ) . withTypeProvider < TypeBoxTypeProvider > ( ) ;
198
207
199
- fastify . addHook ( 'onReady' , waitForNode ) ;
208
+ if ( serverOpts . wait_for_chainhook_node ) {
209
+ fastify . addHook ( 'onReady' , waitForNode ) ;
210
+ }
200
211
fastify . addHook ( 'onReady' , registerPredicates ) ;
201
212
fastify . addHook ( 'onClose' , removePredicates ) ;
202
213
0 commit comments