Skip to content

Commit

Permalink
fix(thunk): run thunk supervisors immediately on register
Browse files Browse the repository at this point in the history
For whatever reason, dispatching actions to register all the supervisor
thunks was too slow and causing a regression with prod systems.

This reverts part of the register function to how it used to work.  To
be more specific, it calls the supervisor functions immediately in a
`parallel` call.
  • Loading branch information
neurosnap committed Aug 16, 2024
1 parent 56f96ae commit 2a61af0
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions query/thunk.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { compose } from "../compose.ts";
import type { ActionWithPayload, AnyAction, Next, Payload } from "../types.ts";
import { ActionContext, createAction, put, takeEvery } from "../action.ts";
import { ActionContext, createAction, takeEvery } from "../action.ts";
import { isFn, isObject } from "./util.ts";
import { createKey } from "./create-key.ts";
import type {
Expand All @@ -14,7 +14,7 @@ import type {
} from "./types.ts";
import { API_ACTION_PREFIX } from "../action.ts";
import { Callable, Ok, Operation, Signal, spawn } from "../deps.ts";
import { supervise } from "../fx/mod.ts";
import { keepAlive, supervise } from "../fx/mod.ts";

const registerThunk = createAction<Callable<unknown>>(
`${API_ACTION_PREFIX}REGISTER_THUNK`,
Expand Down Expand Up @@ -258,7 +258,7 @@ export function createThunks<Ctx extends ThunkCtx = ThunkCtx<any>>(
});

// register any thunks already created
yield* put(Object.values(visors).map(registerThunk));
yield* keepAlive(Object.values(visors));

yield* task;
}
Expand Down

0 comments on commit 2a61af0

Please sign in to comment.