File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -244,6 +244,20 @@ export const layer = Layer.effect(
244244 } ) . pipe ( Effect . ignore )
245245 }
246246
247+ yield * Effect . addFinalizer ( ( ) =>
248+ Effect . forEach (
249+ hooks ,
250+ ( hook ) =>
251+ Effect . tryPromise ( {
252+ try : ( ) => Promise . resolve ( hook . dispose ?.( ) ) ,
253+ catch : ( error ) => {
254+ log . error ( "plugin dispose hook failed" , { error } )
255+ } ,
256+ } ) . pipe ( Effect . ignore ) ,
257+ { discard : true } ,
258+ ) ,
259+ )
260+
247261 // Subscribe to bus events, fiber interrupted when scope closes
248262 yield * ( yield * bus . subscribeAll ( ) ) . pipe (
249263 Stream . runForEach ( ( input ) =>
Original file line number Diff line number Diff line change @@ -220,6 +220,7 @@ export type ProviderHook = {
220220export type AuthOuathResult = AuthOAuthResult
221221
222222export interface Hooks {
223+ dispose ?: ( ) => Promise < void >
223224 event ?: ( input : { event : Event } ) => Promise < void >
224225 config ?: ( input : Config ) => Promise < void >
225226 tool ?: {
You can’t perform that action at this time.
0 commit comments