Prevent infinite recursion in response tag

Closes yaakapp/app#90
This commit is contained in:
Gregory Schier
2024-09-16 06:37:48 -07:00
parent 75df5f8094
commit 29d2d0ec62

View File

@@ -39,7 +39,6 @@ export const plugin: Plugin = {
if (httpRequest == null) {
return null;
}
const renderedHttpRequest = await ctx.httpRequest.render({ httpRequest, purpose: args.purpose });
const responses = await ctx.httpResponse.find({ requestId: httpRequest.id, limit: 1 });
@@ -57,6 +56,8 @@ export const plugin: Plugin = {
// Send if no responses and "smart," or "always"
if ((behavior === 'smart' && response == null) || behavior === 'always') {
// NOTE: Render inside this conditional, or we'll get infinite recursion (render->render->...)
const renderedHttpRequest = await ctx.httpRequest.render({ httpRequest, purpose: args.purpose });
response = await ctx.httpRequest.send({ httpRequest: renderedHttpRequest });
}