Open fabiancook opened 1 year ago
We have a maximum time a function can run for, a task should give up after that time
A new abort controller should be available for every request The controller should be set on the fastify request context
const controller = new AbortController(); requestContext.set(ABORT_CONTROLLER, controller);
We should be able to get the signal anywhere using the context
function getAbortController() { const controller = requestContext.get(ABORT_CONTROLLER); ok(controller, "Expected AbortController to be available"); return controller; } function getSignal() { return getAbortController().signal; }
The abort controller should be aborted once the timeout hits
const timeout = setTimeout(() => controller.abort()); requestContext.set(ABORT_TIMEOUT, timeout);
When the request finishes before the timeout we want to clear this timeout
const timeout = requestContext.get(ABORT_TIMEOUT); clearTimeout(timeout);
We have a maximum time a function can run for, a task should give up after that time
A new abort controller should be available for every request The controller should be set on the fastify request context
We should be able to get the signal anywhere using the context
The abort controller should be aborted once the timeout hits
When the request finishes before the timeout we want to clear this timeout