@@ -126,37 +126,41 @@ async function respondWithExecApprovalsNodePayload<TParams extends { nodeId: str
126126}
127127
128128export const execApprovalsHandlers : GatewayRequestHandlers = {
129- "exec.approvals.get" : ( { params, respond } ) => {
129+ "exec.approvals.get" : async ( { params, respond } ) => {
130130 if ( ! assertValidParams ( params , validateExecApprovalsGetParams , "exec.approvals.get" , respond ) ) {
131131 return ;
132132 }
133- ensureExecApprovals ( ) ;
134- const snapshot = readExecApprovalsSnapshot ( ) ;
135- respond ( true , toExecApprovalsPayload ( snapshot ) , undefined ) ;
133+ await respondUnavailableOnThrow ( respond , async ( ) => {
134+ ensureExecApprovals ( ) ;
135+ const snapshot = readExecApprovalsSnapshot ( ) ;
136+ respond ( true , toExecApprovalsPayload ( snapshot ) , undefined ) ;
137+ } ) ;
136138 } ,
137- "exec.approvals.set" : ( { params, respond } ) => {
139+ "exec.approvals.set" : async ( { params, respond } ) => {
138140 if ( ! assertValidParams ( params , validateExecApprovalsSetParams , "exec.approvals.set" , respond ) ) {
139141 return ;
140142 }
141- ensureExecApprovals ( ) ;
142- const snapshot = readExecApprovalsSnapshot ( ) ;
143- if ( ! requireApprovalsBaseHash ( params , snapshot , respond ) ) {
144- return ;
145- }
146- const incoming = ( params as { file ?: unknown } ) . file ;
147- if ( ! incoming || typeof incoming !== "object" ) {
148- respond (
149- false ,
150- undefined ,
151- errorShape ( ErrorCodes . INVALID_REQUEST , "exec approvals file is required" ) ,
152- ) ;
153- return ;
154- }
155- const normalized = normalizeExecApprovals ( incoming as ExecApprovalsFile ) ;
156- const next = mergeExecApprovalsSocketDefaults ( { normalized, current : snapshot . file } ) ;
157- saveExecApprovals ( next ) ;
158- const nextSnapshot = readExecApprovalsSnapshot ( ) ;
159- respond ( true , toExecApprovalsPayload ( nextSnapshot ) , undefined ) ;
143+ await respondUnavailableOnThrow ( respond , async ( ) => {
144+ ensureExecApprovals ( ) ;
145+ const snapshot = readExecApprovalsSnapshot ( ) ;
146+ if ( ! requireApprovalsBaseHash ( params , snapshot , respond ) ) {
147+ return ;
148+ }
149+ const incoming = ( params as { file ?: unknown } ) . file ;
150+ if ( ! incoming || typeof incoming !== "object" ) {
151+ respond (
152+ false ,
153+ undefined ,
154+ errorShape ( ErrorCodes . INVALID_REQUEST , "exec approvals file is required" ) ,
155+ ) ;
156+ return ;
157+ }
158+ const normalized = normalizeExecApprovals ( incoming as ExecApprovalsFile ) ;
159+ const next = mergeExecApprovalsSocketDefaults ( { normalized, current : snapshot . file } ) ;
160+ saveExecApprovals ( next ) ;
161+ const nextSnapshot = readExecApprovalsSnapshot ( ) ;
162+ respond ( true , toExecApprovalsPayload ( nextSnapshot ) , undefined ) ;
163+ } ) ;
160164 } ,
161165 "exec.approvals.node.get" : async ( { params, respond, context } ) => {
162166 await respondWithExecApprovalsNodePayload ( {
0 commit comments