-
Notifications
You must be signed in to change notification settings - Fork 8
Open
Labels
enhancementNew feature or requestNew feature or requestgood first issueGood for newcomersGood for newcomers
Description
I just found this plugin after already using piscina in fastify. I've decorated my request with an abortSignal:
const { AbortController } = require('abort-controller');
module.exports = function (fastify) {
fastify.decorateRequest('abortSignal', null);
fastify.addHook('onRequest', (req, reply, done) => {
let controller = new AbortController();
req.raw.once('close', () => {
controller.abort();
});
req.abortSignal = controller.signal;
done();
});
};So I can do this in a request handler
await piscina.runTask(task, req.abortSignal);I'm not sure how reliable this is, but I needed to abort expensive tasks when the client cancels the fetch in the browser via AbortController (I'm using this in an Electron app). Would it make sense to integrate something like this into the plugin? The semantic is somewhat inspired by Golang context.
Metadata
Metadata
Assignees
Labels
enhancementNew feature or requestNew feature or requestgood first issueGood for newcomersGood for newcomers