Skip to content

Commit 76d002b

Browse files
authored
Fix mem leaks by claude (#1538)
Signed-off-by: Marcos Candeia <marrcooos@gmail.com>
1 parent c7753c3 commit 76d002b

5 files changed

Lines changed: 22 additions & 11 deletions

File tree

vtex/actions/analytics/sendEvent.ts

Lines changed: 14 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -63,16 +63,21 @@ const action = async (
6363
throw new Error("Missing IS Cookies");
6464
}
6565

66-
await sp["POST /event-api/v1/:account/event"]({ account: ctx.account }, {
67-
body: {
68-
...props,
69-
...cookies,
70-
agent: req.headers.get("user-agent") || "deco-sites/apps",
66+
const response = await sp["POST /event-api/v1/:account/event"](
67+
{ account: ctx.account },
68+
{
69+
body: {
70+
...props,
71+
...cookies,
72+
agent: req.headers.get("user-agent") || "deco-sites/apps",
73+
},
74+
headers: {
75+
"content-type": "application/json",
76+
},
7177
},
72-
headers: {
73-
"content-type": "application/json",
74-
},
75-
});
78+
);
79+
80+
await response.body?.cancel();
7681

7782
return null;
7883
};

vtex/actions/newsletter/subscribe.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,9 +33,10 @@ const action = async (
3333
form.append("newsInternalPart", part);
3434
form.append("newsInternalCampaign", campaing);
3535

36-
await vcsDeprecated["POST /no-cache/Newsletter.aspx"]({}, {
36+
const response = await vcsDeprecated["POST /no-cache/Newsletter.aspx"]({}, {
3737
body: form,
3838
});
39+
await response.body?.cancel();
3940
};
4041

4142
export default action;

vtex/actions/notifyme.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,10 @@ const action = async (
2424
form.append("notifymeClientEmail", email);
2525
form.append("notifymeIdSku", skuId);
2626

27-
await vcsDeprecated["POST /no-cache/AviseMe.aspx"]({}, { body: form });
27+
const response = await vcsDeprecated["POST /no-cache/AviseMe.aspx"]({}, {
28+
body: form,
29+
});
30+
await response.body?.cancel();
2831
};
2932

3033
export default action;

website/utils/image/engines/remote/engine.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ export const createEngine = (
1818
const response = await fetch(url, { headers: new Headers(req.headers) });
1919

2020
if (!response.ok) {
21+
await response.body?.cancel();
2122
throw new HttpError(502);
2223
}
2324

website/utils/image/engines/wasm/engine.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,7 @@ const fetchImage = async (
5959
const response = await fetch(src, init);
6060

6161
if (!response.ok) {
62+
await response.body?.cancel();
6263
throw new HttpError(response.status, Deno.inspect(response));
6364
}
6465

0 commit comments

Comments
 (0)