Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .changeset/llhi-sqkr-oest.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"ff-effect": patch
---

Fix memory leak in Inngest handler: scope step FiberSets per invocation instead of leaking finalizers into the long-lived app scope
18 changes: 9 additions & 9 deletions packages/effect/src/for/inngest/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ import type {
InngestFunction,
} from 'inngest';
import { serve } from 'inngest/bun';
import { extract } from '../../extract';
import { cronToString } from './cron';
import { wrapStep } from './step';

Expand Down Expand Up @@ -114,7 +113,6 @@ export function createInngest<
) =>
Effect.gen(function* () {
const c = yield* Tag;
const ext_handler = yield* extract(handler);
const resolvedTrigger = resolveTrigger<TClient>(trigger);
const runPromise = yield* FiberSet.makeRuntimePromise();

Expand All @@ -125,13 +123,15 @@ export function createInngest<
async (ctx: any) => {
const effectStep = wrapStep(ctx.step);
return runPromise(
ext_handler({
...ctx,
step: effectStep,
} as unknown as EffectHandlerCtx<
TClient,
ExtractTriggerName<TClient, TTrigger>
>),
Effect.scoped(
handler({
...ctx,
step: effectStep,
} as unknown as EffectHandlerCtx<
TClient,
ExtractTriggerName<TClient, TTrigger>
>),
) as unknown as Effect.Effect<unknown, unknown, never>,
);
},
) as unknown as InngestFunction.Any;
Expand Down
Loading