Skip to content

generatePermutations Fail for empty flags #258

@eudago

Description

@eudago

There’s an issue that occurs when we run out of flags. The Flags SDK still generates code for the page, which is fine up to that point. The problem appears when we call generatePermutations with an empty array.
I need this because we have an endpoint to revalidate these pages, and if multiple pages have been generated, we need to revalidate all of them.

Example:

export const productPageFlags = [] as const;

const codes = await generatePermutations(productPageFlags);
⨯ TypeError: items.at is not a function or its return value is not iterable
    at cartesianIterator.next (<anonymous>)
    at POST (src/app/(api)/nextjs/api/revalidate/path/route.ts:80:49)
  79 |     if (isProductPage) {
> 80 |         const codes = await generatePermutations(productPageFlags);

If all the flags have been removed because we no longer want to use them, but might want them again in the future, how should we handle this situation?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions