Add cancelHook for plugins #3727
Replies: 4 comments
-
👋 Thanks for opening your first issue! If you're reporting a 🐞 bug, please make sure To help make this a smooth process, please be sure you have first read the |
Beta Was this translation helpful? Give feedback.
-
This should definitely be addressed. Thank you for pointing it out. It's quite an edge case. The reason it currently doesn't work is because canceling the prompt modal causes the render step to fail, resulting in an exception, which then does not go through the response hooks. There may be other reasons why exceptions are thrown as well. For example, general render errors, misconfigured settings, validation errors, etc. I think a generic |
Beta Was this translation helpful? Give feedback.
-
I have now noticed it also happens when you make a typo and you get exceptions such as hostname could not be resolved so indeed, a general requestErrorHooks plugin could make sense. |
Beta Was this translation helpful? Give feedback.
-
Looks like this had been part of the plan a year and a half ago: #1841 |
Beta Was this translation helpful? Give feedback.
-
Details
I think it could be useful to make available cancel hooks in the plugins, similar to the response hooks.
Use case:
When I do not specify a storage key in the prompt plugin, I expect to get reprompted for every request. This works fine, provided the request results in a response, which cleans up the cache through the response hook.
However, if I cancel the request (for instance, because it cannot be fulfilled and I do not want to enforce timeouts), I need to restart the application to clear the cache.
I could (and have) modified the prompt plugin to include a flag to reprompt every time, but this is not the ideal behaviour either as prompts could be rendered multiple times for a single request.
The ideal solution would be to have a form of cancelHook, which allows for cleanup of the cache upon cancellation of the request.
Beta Was this translation helpful? Give feedback.
All reactions