Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion packages/lib/queries.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ export const fetchSubscriptionStatus = (
await Promise.all(
allPlans.map(async (plan) => {
try {
const res = autumn.check({
const res = await autumn.check({
productId: plan,
})
const allowed = res.data?.allowed ?? false
Comment on lines 23 to 29
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Bug: The autumn.check() call is not awaited in fetchMemoriesFeature and other similar functions, causing them to return undefined instead of the expected data.
Severity: MEDIUM

Suggested Fix

Add the await keyword to the autumn.check() call in all affected functions (fetchMemoriesFeature, fetchConnectionsFeature, fetchConsumerProProduct, fetchProProduct) to ensure the promise resolves before accessing the .data property. For example, change const res = autumn.check(...) to const res = await autumn.check(...).

Prompt for AI Agent
Review the code at the location below. A potential bug has been identified by an AI
agent.
Verify if this is a real issue. If it is, propose a fix; if not, explain why it's not
valid.

Location: packages/lib/queries.ts#L23-L29

Potential issue: In several query functions, including `fetchMemoriesFeature`,
`fetchConnectionsFeature`, `fetchConsumerProProduct`, and `fetchProProduct`, the
asynchronous call to `autumn.check()` is not awaited. This causes the `res` variable to
be a Promise object instead of the resolved value. Consequently, `res.data` evaluates to
`undefined`. Downstream hooks and components that consume these functions, such as
`use-memories-usage.ts`, then receive `undefined` data. This leads to incorrect UI
displays, like showing resource usage as "0 / 0" instead of the actual values, which can
mislead users about their account status and limits.

Did we get this right? 👍 / 👎 to inform future reviews.

Expand Down